Installation guide

126 Chapter 12. Managing Files and Directories
often or files that you want to save but do not use anymore. You can even create an archive file and
then compress it to save disk space.
Important
An archive file is not compressed, but a compressed file can be an archive file.
12.3.1. File Compressing
Compressed files use less disk space and download faster than large, uncompressed files. In Red Hat
Linux you can compress files with the compression tools gzip, bzip2, or zip.
The bzip2 compression tool is recommended because it provides the most compression and is found
on most UNIX-like operating systems. The gzip compression tool can also be found on most UNIX-
like operating systems. If you need to transfer files between Linux and other operating system such
as MS Windows, you should use zip because it is more commonly used on these other operating
systems.
Compression Tool File
Extension
Uncompression Tool
gzip .gz gunzip
bzip2 .bz2 bunzip2
zip .zip unzip
Table 12-1. Compression Tools
By convention, files compressed with gzip are given the extension .gz, files compressed with bzip2
are given the extension .bz2, and files compressed with zip are given the extension .zip.
Files compressed with gzip are uncompressed with gunzip, files compressed with bzip2 are un-
compressed with bunzip2, and files compressed with zip are uncompressed with unzip.
12.3.1.1. Bzip2 and Bunzip2
To use bzip2 to compress a file type the following command at a shell prompt:
bzip2 filename
The file will be compressed and saved as filename.bz2.
To expand the compressed file, type the following command:
bunzip2 filename.bz2
The filename.bz2 is deleted and replaced with filename.
You can bzip2 multiple files and directories at the same time by listing them with a space between
each one:
bzip2 filename.bz2 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.bz2.