Книга: Fedora™ Unleashed, 2008 edition
Working with Compressed Files
Working with Compressed Files
Another file management operation is compression and decompression of files, or the creation, listing, and expansion of file and directory archives. Linux distributions usually include several compression utilities you can use to create, compress, expand, or list the contents of compressed files and archives. These commands include the following:
? bunzip2
— Expands a compressed file
? bzip2
— Compresses or expands files and directories
? gunzip
— Expands a compressed file
? gzip
— Compresses or expands files and directories
? shar file
— Creates a shell archive of files
? tar
— Creates, expands, or lists the contents of compressed or uncompressed file or directory archives known as tape archives or tarballs
Most of these commands are easy to use. The tar command, however, has a somewhat complex (although capable) set of command-line options and syntax. Even so, you can quickly learn to use tar by remembering a few simple invocations on the command line. For example, to create a compressed archive of a directory, use tar's czf
options like this:
$ tar czf dirname.tgz dirname
The result is a compressed archive (a file ending in .tgz
) of the specified directory (and all files and directories under it). Add the letter v
to the preceding options to view the list of files added during compression and archiving. To list the contents of the compressed archive, substitute the c
option with the letter t, as follows:
$ tar tzf archive
Of course, if many files are in the archive, a better invocation (to easily read or scroll through the output) is the following:
$ tar tzf archive | less
To expand the contents of a compressed archive, use tar's zxf
options, like so:
$ tar zxf archive
The tar
utility decompresses the specified archive and extracts the contents in the current directory.
- Navigating Through the File System
- Managing Files with the Shell
- Working with Compressed Files
- Use Essential Commands from the /bin and /sbin Directories
- Use and Edit Files in the /etc Directory
- Protect the Contents of User Directories — /home
- Use the Contents of the /proc Directory to Interact with the Kernel
- Work with Shared Data in the /usr Directory
- Temporary File Storage in the /tmp Directory
- Access Variable Data Files in the /var Directory
- Work with Shared Data in the
- Access Variable Data Files in the
- Working As Root
- 6.4.2. Booting with initrd
- Expanding compressed drives
- Expanding compressed directories and files
- Working with Files and Directories
- 14. Files and File I
- Adding New Files to an SDK
- SERVER WORKING SIZE
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- Drawbacks with restore