To compress an entire folder and its’ contents in Linux you use the tar, (Tape ARchive), command. The tar command is used as follows:
tar -zcf archive-name.tar.gz /home/andy/temp
Where:
- z: compress archive using gzip program
- c: create archive
- f: archive file name
The command above will create a new, compressed, archive file called archive-name.tar.gz in current directory. The contents of the archive file will be the contents of the /home/andy/temp folder.
In order to restore your archive then you need to use following command (it will extract all files in current directory):
tar -zxf archive-name.tar.gz
Where,
- -x: Extract files