348
Networking: A Beginner's Guide
To create a gzipped compressed archive called apache.tar.gz containing all the files
from /usr/src/apache and list the files as they are being added to the archive, type the
following:
[root@ford src]# tar -cvzf apache.tar.gz /usr/src/apache
To extract the contents of a gzipped tar archive called apache.tar.gz and list the files
as they are being extracted, type the following:
[root@ford /root]# tar -xvzf apache.tar.gz
cat: Concatenate Files
The cat program serves a simple purpose: to display the contents of files. While you
can do more creative things with it, you will almost always use the program simply to
display the contents of text files, much like you would use the type command under
DOS. Because you can specify multiple filenames on the command line, it is possible to
concatenate files into a single large continuous file. Thus, cat differs from tar in that the
resulting file has no control information to show the boundaries of different files.
For example, to display the /etc/passwd file, type the following:
[root@ford /root]# cat /etc/passwd
To display the /etc/passwd file and the /etc/group file, type the following:
[root@ford /root]# cat /etc/passwd /etc/group
To concatenate the /etc/passwd file with the /etc/group file into the /tmp/
complete file, type the following:
[root@ford /root]# cat /etc/passwd /etc/group > /tmp/complete
To concatenate the /etc/passwd file to an existing file called /tmp/orb, type the
following:
[root@ford /root]# cat /etc/passwd >> /tmp/orb
Options
Descriptions
-c
Create a new archive.
-t
View the contents of an archive.
-x
Extract the contents of an archive.
-f
Specify the name of the file (or device) in which the archive is located.
-v
Be verbose during operations.
-z
Assume that the file is already (or will be) compressed with gzip.
Table 21-8.
Common tar Command Options