Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Zip Unzip / Compress Uncompress Archive files on linux

By editor , 12 December, 2015
Question

Zip and Unzip Files on Linux (With zip and unzip)
Compress Uncompress Archive on linux

Zip and Unzip Files on Linux (With zip and unzip)

Ziping files/directories
zip file *
zip -r file *

Unziping files/directories
unzip  file.zip

extract a file
unzip file.zip  file.doc

Extract all files into a directory
unzip file.zip  -d /home/dir

List all files from file.zip
unzip -l file.zip

Compress Uncompress Archive on linux

Tar Command in Linux

  • c - Creates a new .tar archive file
  • v - Verbosely show the .tar file progress
  • f - File name type of the archive file
  • z - Compressed
  • C - Specified directory
  • x - Extract
  • t - List


Create tar Archive File
tar -cvf file.tar /home/dir/

Create tar.gz Archive File
tar -cvzf file.tar.gz /home/dir
tar -cvzf file.tgz /home/dir

Create tar.bz2 Archive File
tar -cvfj file.tar.bz2 /home/php
tar -cvfj file.tar.tbz /home/php
tar -cvfj file.tar.tb2 /home/php

Untar tar Archive File
tar -xvf file.tar
tar -xvf file.tar -C /home/dir
#Extract to a directory

Uncompress tar.gz Archive File
tar -xvf file.tar.gz

List Content tar.gz Archive File
tar -tvf file.tar.gz

List Content tar.bz2 Archive File
tar -tvf file.tar.bz2

 

Compress
$ gzip file1 file2 file3
NOTE : gzip used to compress a single file and it is unable to compress a folder . To compress a folder, use tar -z

Extract GZ file (Using gzip / guzip)
$ gzip -d file.gz
OR
$ gunzip file.gz
 

Other Tar Zip Operations on Linux CLI

Delete a File From a Tar file

tar --delete -f example.tar file_to_delete.txt

 

 

Tags

  • Linux
  • Shell

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer