The utilities introduced in this chapter are a small but powerful subset of the many utilities available on a Red Hat 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 Table 5-2 manipulate, display, compare, and print files. Table 5-2. File utilitiesUtility | Function |
---|
cp | Copies one or more files (page 129) | diff | Displays the differences between two files (page 135) | file | Displays information about the contents of a file (page 135) | grep | Searches file(s) for a string (page 131) | head | Displays the lines at the beginning of a file (page 132) | lpq | Displays a list of jobs in the print queue (page 131) | lpr | Places file(s) in the print queue (page 131) | lprm | Removes a job from the print queue (page 131) | mv | Renames a file or moves file(s) to another directory (page 130) | sort | Puts a file in order by lines (page 133) | tail | Displays the lines at the end of a file (page 132) | uniq | Displays the contents of a file, skipping successive duplicate lines (page 134) |
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. Table 5-3 lists utilities that compress and decompress files. The bzip2 utility is the most efficient of these. Table 5-3. (De)compression utilitiesUtility | Function |
---|
bunzip2 | Returns a file compressed with bzip2 to its original size and format (page 140) | bzcat | Displays a file compressed with bzip2 (page 140) | bzip2 | Compresses a file (page 140) | compress | Compresses a file (not as well as gzip) (page 141) | gunzip | Returns a file compressed with gzip or compress to its original size and format (page 141) | gzip | Compresses a file (page 141) | zcat | Displays a file compressed with gzip (page 141) |
An archive is a file, frequently compressed, that contains a group of files. The tar utility (Table 5-4) 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 utilityUtility | Function |
---|
tar | Creates or extracts files from an archive file (page 141) |
The utilities listed in Table 5-5 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 utilitiesUtility | Function |
---|
apropos | Searches the man page one-line descriptions for a keyword (page 145) | locate | Searches for files on the local system (page 146) | whereis | Displays the full pathnames of a utility, source code, or man page (page 144) | which | Displays the full pathname of a command you can run (page 144) |
Table 5-6 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 utilitiesUtility | Function |
---|
finger | Displays detailed information about users, including their full names (page 147) | hostname | Displays the name of the local system (page 129) | w | Displays detailed information about users who are logged in (page 149) | who | Displays information about users who are logged in (page 147) |
The utilities shown in Table 5-7 can help you stay in touch with other users on the local network. Table 5-7. User communication utilitiesUtility | Function |
---|
mesg | Permits or denies messages sent by write (page 151) | write | Sends a message to another user who is logged in (page 150) |
Table 5-8 lists miscellaneous utilities. Table 5-8. Miscellaneous utilitiesUtility | Function |
---|
date | Displays the current date and time (page 137) | echo | Copies its arguments (page 1019) to the screen (page 137) |
|