Linux/Unix 101: Using “tar” And “gzip” To Create and Extract Files From Archives

The tar program is used to collect many files into one larger file usually for archival purposes.

The gzip program is used to compress large files.

Creating a compressed tar file:

tar cvf archive.tar some_directory/
gzip -9 archive.tar

The first command creates the file archive.tar which contains a copy of all files and subdirectories in some_directory. The second command compresses (with maximum compression) the archive.tar file and renames it to archive.tar.gz to indicate that it is compressed.

To get your files out of the compressed archive, you do the reverse – uncompress and then untar.

gunzip archive.tar.gz
tar xvf archive.tar
You can leave a response, or trackback from your own site.

Leave a Reply