User Tools

Site Tools


linux:tar_gzip

This is an old revision of the document!


Tar and GZIP

Compress and Zip

tar -zcvf website.tar.gz /var/www
  • -z : Compress archive using gzip program in Linux or Unix
  • -c : Create archive on Linux
  • -v : Verbose i.e display progress while creating archive
  • -f : Archive File name

Untar

tar xfz foo.tar.gz

To untar in verbose mode, add v to the list of arguments.

Remove the z if it is not a zipped tar

Untar to Specific Directory

tar -xzf foo.tar.gz -C /tmp/foo/;

Tar

To tar all *.txt files into foo.tar.gz

tar cfz foo.tar.gz *.txt

To tar without compressing, remove the

z

from the list of arguments.

Tar Directory

tar cf foo.tar.gz some_directory/

List Contents of Tar

tar tvf foo.tar

Gzip

To gzip a file

gzip filename

Uncompress .Z Files

uncompress filename.tar.Z

Install 7zip

You will need to have installed rpmforge repository on you computer.

yum install p7zip

You can then use 7zip with the command 7za

Compress with 7zip

adds all files from directory “dir1” to archive archive.7z using “ultra settings”

7za -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1

Uncompress with 7zip

7za x zrchive.7z
linux/tar_gzip.1592646198.txt.gz · Last modified: (external edit)