Installation guide

Chapter 12. Managing Files and Directories 127
Tip
For more information, type man bzip2 and man bunzip2 at a shell prompt to read the man pages for
bzip2 and bunzip2.
12.3.1.2. Gzip and Gunzip
To use gzip to compress a file, type the following command at a shell prompt:
gzip filename
The file will be compressed and saved as filename.gz.
To expand the compressed file, type the following command:
gunzip filename.gz
The filename.gz is deleted and replaced with filename.
You can gzip multiple files and directories at the same time by listing them with a space between
each one:
gzip -r filename.gz file1 file2 file3 /usr/work/school
The above command compresses file1, file2, file3, and the contents of the
/usr/work/school directory (assuming this directory exists) and put them in filename.gz.
Tip
For more information, type man gzip and man gunzip at a shell prompt to read the man pages for
gzip and gunzip.
12.3.1.3. Zip and Unzip
To compress a file with zip, type the following command:
zip -r filename.zip filesdir
In this example, filename.zip represents the file you are creating and filesdir represents the
directory you want to put in the new zip file. The -r option specifies that you want to include all files
contained in the filesdir directory recursively.
To extract the contents of a zip file, type the following command:
unzip filename.zip
You can zip multiple files and directories at the same time by listing them with a space between each
one:
zip -r filename.zip file1 file2 file3 /usr/work/school
The above command compresses file1, file2, file3, and the contents of the
/usr/work/school directory (assuming this directory exists) and put them in filename.zip.