-->
Previous Table of Contents Next


Viewing Online-Manual Pages with Man

One of the handiest feature of UNIX—and by extension, of Linux—is the existence of online-manual pages, which detail the workings of specific commands. These online-manual pages (commonly referred to as man pages) will list the purpose of a given command, any command-line options, and perhaps other information. (For example, man pages created by the FSF for use with GNU commands tend to be rather verbose, going into the entire purpose of the command and listing any known bugs.) While this sort of information isn’t as useful as a full online help system (for example, you can’t look up a man page for any topics at all; man pages are written for specific commands), it still can help you a great deal, especially if you know a certain command can come close to doing what you want, but you need to know the precise option that yields the desired behavior.

To view an online-manual page, combine the name of the command with the man command:


     gilbert:/$ man man

You’ll then see the information shown in Figure 4.1.


Figure 4.1  The man command in action.

The man page for man is obviously a multipage document, as evidenced by the information at the bottom of the screen, because the bottom sentence isn’t complete. To move up and down through the entire man page by entire pages, use the PageUp and PageDown keys; to move up and down the man page line by line, use the keyboard cursor keys ([uarr] and [darr]). To quit the man command and get a command prompt, press the q key (short for quit).


NOTE:  There’s an X Window equivalent of man, called xman, shown in Figure 4.2. You should use this command when running XFree86.


Figure 4.2  The xman command in action.


NOTE:  The bash shell contains its own help mechanism, which will be covered later in this chapter.

Finding Files

The find command included with Linux (actually the GNU find command) is very similar to the find command that ships with most other versions of UNIX—that is, the GNU version is maddeningly complex and nonintuitive to use. At its best, find will search your entire filesystem for a specific file. At its worse, find will return every file on the system, leaving you scratching your head about how to proceed with a useful search.

Still, you shouldn’t run into too many problems with find if you remember one thing: You need to make sure all the elements of the command line are properly organized. For example, you won’t find the following command line very useful:


     gilbert:~$ find *

as it returns all the files in your current directory. Similarly, the following command line will list every file (at a dizzying speed, no less) on your Linux system:


     gilbert:/$ find *

a move guaranteed to give you a headache. (Remember, Linux does exactly what you tell it to do.)

Instead, you’ll need to slow down and figure out how to use the find command. Let’s say you want to find the directory location of a file named test.bk. First, you need to tell find how to search for a file. We know the name of the file, so we begin our command line by telling find to search by filename. We do so with the -name option:


     gilbert:/$ find * -name

This is a start. Now we need to tell find what to look for. We do this by adding the name of the file:


     gilbert:~$ find * -name test.bk

If you wanted, you could use a wildcard instead of listing the specific filename. With or without a wildcard, however, the command should work.

If you’re working with a large filesystem, you may want to run the find command in the background. This is accomplished by adding an ampersand to the command line:


     gilbert:~$ find * -name test.bk &

Running this command in the background allows you to do work while the find command searches for the file. For more information on running commands in the background, check out the section “Background Commands and Multitasking” later in this chapter.


NOTE:  When looking at other Linux texts, you’ll be able to see who actually wrote the book using Linux and who wrote the book with a knowledge of UNIX and not much experience with Linux by the way the find command is explained. In most versions of UNIX, the find command requires that -print be added to the end of the command line and that the name of the search be in quotation marks. The GNU version of find requires neither.

There’s a lot more to the find command, as it encompasses an amazing amount of complexity that’s meant for large-scale systems more than for the needs of the average Linux user. If you’re interested in knowing more about the find command, use the following command line:


     gilbert:~$ man find


Previous Table of Contents Next