Chapter Summary

Chapter Summary

The utilities introduced in this chapter are a small but powerful subset of the many utilities available on a CentOS Linux system. Because you will use them frequently and because they are integral to the following chapters, it is important that you become comfortable using them.

The utilities listed in manipulate, display, compare, and print files.

Table 5-2. File utilities

Utility

Function

cp

Copies one or more files (page )

diff

Displays the differences between two files (page )

file

Displays information about the contents of a file (page )

grep

Searches file(s) for a string (page )

head

Displays the lines at the beginning of a file (page )

lpq

Displays a list of jobs in the print queue (page )

lpr

Places file(s) in the print queue (page )

lprm

Removes a job from the print queue (page )

mv

Renames a file or moves file(s) to another directory (page )

sort

Puts a file in order by lines (page )

tail

Displays the lines at the end of a file (page )

uniq

Displays the contents of a file, skipping successive duplicate lines (page )


To reduce the amount of disk space a file occupies, you can compress it with the bzip2 utility. Compression works especially well on files that contain patterns, as do most text files, but reduces the size of almost all files. The inverse of bzip2bunzip2restores a file to its original, decompressed form. lists utilities that compress and decompress files. The bzip2 utility is the most efficient of these.

Table 5-3. (De)compression utilities

Utility

Function

bunzip2

Returns a file compressed with bzip2 to its original size and format (page )

bzcat

Displays a file compressed with bzip2 (page )

bzip2

Compresses a file (page )

compress

Compresses a file (not as well as gzip) (page )

gunzip

Returns a file compressed with gzip or compress to its original size and format (page )

gzip

Compresses a file (page )

zcat

Displays a file compressed with gzip (page )


An archive is a file, frequently compressed, that contains a group of files. The tar utility () packs and unpacks archives. The filename extensions .tar.bz2, .tar.gz, and .tgz identify compressed tar archive files and are often seen on software packages obtained over the Internet.

Table 5-4. Archive utility

Utility

Function

tar

Creates or extracts files from an archive file (page )


The utilities listed in determine the location of a utility on the local system. For example, they can display the pathname of a utility or a list of C++ compilers available on the local system.

Table 5-5. Location utilities

Utility

Function

apropos

Searches the man page one-line descriptions for a keyword (page )

locate

Searches for files on the local system (page )

whereis

Displays the full pathnames of a utility, source code, or man page (page )

which

Displays the full pathname of a command you can run (page )


lists utilities that display information about other users. You can easily learn a user's full name, the user's login status, the login shell of the user, and other items of information maintained by the system.

Table 5-6. User and system information utilities

Utility

Function

finger

Displays detailed information about users, including their full names (page )

hostname

Displays the name of the local system (page )

w

Displays detailed information about users who are logged in (page )

who

Displays information about users who are logged in (page )


The utilities shown in can help you stay in touch with other users on the local network.

Table 5-7. User communication utilities

Utility

Function

mesg

Permits or denies messages sent by write (page )

write

Sends a message to another user who is logged in (page )


lists miscellaneous utilities.

Table 5-8. Miscellaneous utilities

Utility

Function

date

Displays the current date and time (page )

echo

Copies its arguments (page ) to the screen (page )