How to tar.gz

tar is a program which combine several files into one (eg: files.tar). gz or gzip is a program to compress files (eg: files.gz).
Both are Linux programs. A tar.gz file is a resulting file from several files combined together and then compressed.

To combine and compress a folder:
tar czf filename.tar.gz /path/to/some/folder

To extract a tar.gz file:
tar -zxvf filename.tar.gz

To list all files in a filename.tar.gz:
gunzip -c filename.tar.gz | tar -tvf -

To extract one file from filename.tar.gz:
gunzip -c filename.tar.gz | tar -xvf - somefile.txt

There are also other way to compress and extract, but I personally like this one.

To extract a tar.bz2 file:
tar xvjf filename.tar.bz2

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: