This module was about managing disk space. You learned how to use the
du
command to display disk usage for files and directories. This module also covered three related commands:
compress
,
uncompress
, and
zcat
for managing file compression. In the last half of the module, you learned how to use the
tar
command
when working with archives. You created an archive, listed the archive files, and extracted them.
The zcat command in Unix is used to view the contents of a compressed file, such as a file that has been compressed using gzip or similar compression tools. The zcat command is essentially equivalent to using cat on an uncompressed file.
Here is the basic syntax for the zcat command:
zcat [OPTIONS] [COMPRESSED_FILE]
Here are some common options for the zcat command:
- -h or --help: display help information
- -f or --force: force the decompression of a file, even if it does not have the correct file extension
- -q or --quiet: suppress informational messages
Here are some examples of how to use the zcat command:
- To view the contents of a compressed file:
zcat file.gz
- To view the contents of a compressed file in a pager such as less:
zcat file.gz | less
- To force the decompression of a file with an unknown file extension:
zcat -f unknownfile.xyz
- To view the contents of a compressed file without informational messages:
zcat -q file.gz
The zcat command can be used in combination with other Unix commands to analyze, process or manipulate compressed files. For example, piping the output of zcat to the grep command can be used to search for specific patterns within compressed files.
- Key commands used in Unix for compression
This module introduced the following key UNIX commands:
du
compress
uncompress
zcat
tar
This module introduced you to the following terms and concepts:
- archive: An archive is a set of files that are packaged as a single, large file.
- block: A block is a unit of storage equal to 512 bytes.
- extract: To extract files from an archive means to copy them out of an archive and onto the filesystem.
- disk usage: Disk usage is the amount of storage space your files occupy on the disk.
- file compression: File compression is a way of packing a file\'s contents more efficiently, so that the file takes up less disk space.
- tape device: A tape device is any hardware that contains a tape drive for use with storage media.
- tar file: A tar file is an archive created by the tar command.
- verbose: When a command uses verbose mode, the command displays more than the usual status information. Many UNIX commands accept a -v option that causes them to run in verbose mode.
- .Z extension: When you run the compress command, the resulting files are renamed to end with a .Z extension
In the next module you will learn how to use File Transfer Protocol to send and retrieve files.