Chapter Summary


The utilities introduced in this chapter and Chapter 2 are a small but powerful subset of the utilities available on a Mac OS X 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

cp

Copies one or more files (page 43)

diff

Displays the differences between two files (page 49)

ditto

Copies files and directories (page 44)

file

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

grep

Searches a file for a string (page 46)

head

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

lpq

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

lpr

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

lprm

Removes a job from the print queue (page 46)

mv

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

open

Opens a file (page 42)

script

Records a shell session (page 52)

sort

Puts a file in order by lines (page 49)

tail

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

uniq

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


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, 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 3-3 lists utilities that compress and decompress files. The bzip2 utility is the most efficient of these.

Table 3-3. (De)Compression utilities

bunzip2

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

bzcat

Displays a file compressed with bzip2 (page 55)

bzip2

Compresses a file (page 54)

compress

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

gunzip

Returns a gzipped or compressed file to its original size and format (page 55)

gzcat

Displays a compressed file (page 55)

gzip

Compresses a file (page 55)


An archive is a file, frequently 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

tar

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


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

Table 3-5. Location utilities

apropos

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

type

Locates a utility (page 58)

which

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


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 items of information maintained by the system.

Table 3-6. User and system information utilities

finger

Displays detailed information about users who are logged in, including full names (page 61)

hostname

Displays your system name (page 43)

w

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

who

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


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 or talk (page 64)

write

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


Table 3-8 lists miscellaneous utilities.

Table 3-8. Miscellaneous utilities

date

Displays the current date and time (page 52)

echo

Copies its arguments (page 921) to the terminal (page 52)





A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

Similar book on Amazon

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