Compress/Decompress Files in Linux


Tar and Gzip are two utilities that are very good at compressing one or multiple files into a smaller, single file.

Syntax to Compress


$ tar -cvf - /home | gzip -c > /backups/filedump.tar.gz
This will take the entire /home directory (and all subdirectories) and compress it to /backups/filedump.tar.gz. You can compress just a single file in the same way.

Syntax to Decompress


$ tar xvfz filedump.tar.gz
This decompresses anything in the filedump.tar.gz file.