Chapter Summary

 < Day Day Up > 

The utilities introduced in this chapter and Chapter 2 constitute a small but powerful subset of the many utilities available on a typical 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 3-2 manipulate, display, compare, and print files.

Table 3-2. File utilities

Utility

Function

cp

Copies one or more files (page 45)

diff

Displays the differences between two files (page 51)

file

Displays information about the contents of a file (page 52)

grep

Searches file(s) for a string (page 48)

head

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

lpq

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

lpr

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

lprm

Removes a job from the print queue (page 48)

mv

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

sort

Puts a file in order by lines (page 50)

tail

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

uniq

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


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

Table 3-3. (De)compression utilities

Utility

Function

bunzip2

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

bzcat

Displays a file compressed with bzip2 (page 57)

bzip2

Compresses a file (page 56)

compress

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

gunzip

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

gzip

Compresses a file (page 58)

zcat

Displays a file compressed with gzip (page 58)


An archive is a file, usually compressed, that contains a group of files. The tar utility (Table 3-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 3-4. Archive utility

Utility

Function

tar

Creates or extracts files from an archive file (page 58)


The utilities listed in Table 3-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 system.

Table 3-5. Location utilities

Utility

Function

apropos

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

slocate

Searches for files on the local system (page 63)

whereis

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

which

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


Table 3-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 information maintained by the system.

Table 3-6. User and system information utilities

Utility

Function

finger

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

w

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

who

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


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

Table 3-7. User communication utilities

mesg

Permits or denies messages sent by write (page 68)

write

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


Table 3-8 lists miscellaneous utilities.

Table 3-8. Miscellaneous utilities

date

Displays the current date and time (page 54)

echo

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


     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net