Gzip Compression
To compress a file:
gzip file1
A file by name file1.gz will be created in current directory replacing file1. You can compress multiple files in one go by just specifying their names, separated by spaces. For example:
gzip file1 file2 file3
To expand a gzip compressed file in current directory:
gunzip file1.gz
To compress a directory, you can create a tar and compress it.
tar -czvf name-of-archive.tar.gz /path/to/directory
To compress multiple directories in one file:
tar -czvf name-of-archive.tar.gz /path/directory1 /path/directory2
To extract the a “tar and compressed” directory in your current directory,
tar -xzvf name-of-archive.tar.gz
To extract the a “tar and compressed” directory in a particular directory,
tar -xzvf name-of-archive.tar.gz -C /path/to/directory