![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Complete Idiot's Guide to Linux
Searching for a Tool: aproposMan is very useful if you know the name of the command youre interested in. You can do a man commandname, and you are on your way. But what if you dont know the name of the command you are looking for? That is where the apropos command comes in: It allows you to search for keywords instead. As a result, it displays a list of documents that might be related to your question. Great! Theres only one small hang-up: the database that apropos searches, called the whatis Database, does not exist until you create it. (Youll learn how to do this in the section Building the whatis Database: makewhatis.) After you build it, you can query the database with the apropos command, for example, to find out about commands related to your tape drive: [alberto@digital alberto]$ apropos tape mt (1) - control magnetic tape drive operation smbtar (1) - shell script for backing up SMB shares directly to UNIX tape drive st (4) - SCSI tape device From this information, you know that there are at least three manual pages (use the man command) that relate to your tape drive. The numbers you see in parenthesis indicate a manual section. The UNIX manual is organized into several sections. Each section is organized by topic. Table 15.1 provides a list of the sections.
If you dont specify a section, man will search sections that cover commands first; typically, the order will be sections 1, 8, and 6. It is possible that a command is described in more than one section of the manual. To view a document specific section, specify the man command like this: man section command In the preceding example, the man command is listed twice: in sections 1 and 7. To read the information on section 7, enter this command: man 7 man Getting a Brief Command Description: whatisSometimes you dont care to read five paragraphs of the UNIX manual just to find out what a command does. In those cases, the whatis tool can also be used to obtain a brief description of the command. To operate in this mode, you provide the name of the tool as an argument.
whatis will print out a one-line description of what a command does. I have found that whatis is a great exploration tool. If you go into a program directory such as /sbin, you can quickly learn what the commands there do by issuing this command: cd directory; whatis * This will take you to the directory you specify under directory and issue a whatis on all the files that it finds there. The * is a regular expression that specifies all files it finds in that directory: [alberto@localhost alberto]$ cd /sbin; whatis * adjtimex (2) - tune kernel clock adjtimex (8) - display or set the kernel time variables arp (8) - manipulate the system ARP cache (And more...) Searching Standard Locations: whereisSometimes the help you need is in locating the file or program youre looking for. As explained earlier, your shell finds commands by looking into your environment variable. When you issue the name of a command, the directories listed in the PATH environment variable are searched for a matching command. If found, the command is executed; otherwise, you get the dreaded command not found response. Because some directories holding tools are not included in the default user path, your shell will not see them. In those cases, you can use the whereis tool to find the actual path to the tool you want to use.
Not only does whereis locate a binary, but it will also locate source and manual pages having the name you provide. The format for the command is this: whereis command In the following example, I search for the command passwd: [alberto@digital alberto]$ whereis passwd passwd: /usr/bin/passwd /etc/passwd /etc/passwd.OLD /usr/man/man1/passwd.1 /usr/man/man5/passwd.5 Built-in Command InformationMost recent commands store basic usage information right in the program. Under Linux, you can always try the command name with a --help or -h argument. Typically, the information listed will span more than one screen, so remember to pipe the output through less: commandname --help | less If the command you are using is a smart UNIX command, it will respond in a reasonable way even if it does not understand the --help flag. Typically, when a program encounters an unknown argument, it reverts to spewing its usage information. The usage information will tell you the basic format of the command along with the flags that it supports. Obviously, this wont tell you what the program does (unless you already know), but some information is better than none at all. If man failed, you might need to surf the Web to find some information. I have found that searching the command name in an engine such as Yahoo usually points me in the right direction.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |