gzip and gunzip
gzip (GNU Zip) is the command used to compress files and gunzip (GNU unzip) is command used to decompress files. Files compressed with gzip have a .gz suffix.
Example:
To compress a file using gzip you would type:
gzip file_name Specific Example:
To compress a file name budget.ods (.ods is the extension for an OpenDocument Spreadsheet) you would type:
gzip budget.ods tar (for tar.gz and tar.bz2 files)
tar (tape archive) is the command used to archive/package and extract tar files.
To extract a tar.gz file you would type:
tar -xzvf name_of_archive.tar.gz Specific example:
To extract the file Joomla_1.0.11-Stable-Full_Package.tar.gz in the current directory you would type:
tar -xzvf Joomla_1.0.11-Stable-Full_Package.tar.gz To extract a tar.bz2 file you would type:
tar jxf name_of_archive.tar.bz2
Specific example:
To extract the file Joomla_1.0.11-Stable-Full_Package.tar.bz2 in the current directory you would type:
tar jxf Joomla_1.0.11-Stable-Full_Package.tar.gz
To archive a directory using tar you would type:
tar -czvf file_name.tar.gz directory_to_archive Specific Example:
To create an archive of john_doe's home folder you would type
tar -czvf john_doe.tar.gz /home/john_doe *Note: When tar used to create an archive the file ends up being a compressed tar file with the .gz suffix (gzip compression).
unzip (for .zip files)ZIP archives are most commonly used in Windows/MS-DOS based environments. In Linux, you can use the “unzip” command to extract,list or test ZIP files. Below are the common tasks I use “unzip” for. Extract the contents of a ZIP file into it’s own directory and also create subdirectories as needed. # unzip [filename].zip Extract the contents of a ZIP file into the current directory only. No subdirectories will be created. # unzip -j [filename].zip Extract the contents of a ZIp file into a custom directory. # unzip -d [target directory] [filename].zip List the contents of a ZIP file. # unzip -l [filename].zip Test the integrity of a ZIP file and it’s contents.  # unzip -t [filename].zip # unzip -tq [filename].zip (Only shows summary) Extract the contents of a ZIP file only if the files already exist in the target directory. Good for upgrades. # unzip -f [filename].zip # unzip -fo [filename].zip (non interactive. Yes to all) Extract the contents of a ZIP file if the contents are newer then what’s available in the target directory or don’t exist yet. Good for upgrades. # unzip -u [filename].zip # unzip -uo [filename].zip (non interactive. Yes to all)
|