Sunday, November 2, 2008

How To Get Help In Linux

Sometimes, especially for Windows and Macintosh administrators, a move to the Linux operating system can seem a bit intimidating, especially because of the more traditional approach to administration through the Command Line Interface (CLI). The good news is that Linux includes ample, built-in help including "man" pages, "info", "help", and "apropos". In this article, I'll explain your options and give you some practice using each of them. The information in this article should be applicable in any flavor of Linux.Using "man"formats and displays the online manual pages. There are manual pages for nearly every command imaginable. Unfortunately, many of the man pages assume a fairly extensive background in UNIX, therefore they often require research beyond the initial man page.The man pages are divided into sections. Many man entries appear in only one section, but some might appear in multiple sections such as when a command and a library function have the same name.
The sections that are most likely to be of interest to system and network administrators are sections 1, 5, and 8.
Section 1: user commands
Section 2: system calls
Section 3: library functions
Section 4: special filesSection
Section5: file formats
Section 6: games (introduction)
Section 7: conventions and miscellany
Section 8: administration and privileged commands
Section L: math library functionsSection N: tcl fuctions (Tool command language, a dynamic programming language)You can view a man page as follows (the "#" or "$" is part of the prompt): #man chownThe above command will display the man page for the "chown" command.You can specify a particular section as follows:: #man 1 chmodThe above command would display only section 1 (the user commands section) of the manual for the chmod command. chmod is also a system call, so if you wanted to see the man page for the system call "chmod", you would need to enter the following command: #man 2 chmodUsing "info""info" is an on-line manual reader used by the GNU Project to document utilities. It's similar to man (and often produces identical documents), but offers a standardized set of commands for viewing the documentation. The info utility does not assume as great a depth of UNIX knowledge as man.Basic usage is similar to man: #info chownThe above command will display the info page for the chown command.Info divides its help into nodes instead of sections. A node, like a section in man, describes a specific topic at a specific level of detail. In a moment, I'll show you where to find a tutorial on using info.Using "help"The "help" option is included with most GNU utilities. It displays command options and other information about the utility in question, for example: #ls --helpThe above command would show options and other information about the ls command.Using "apropos""apropos" looks in the description sections of man pages for text strings. When executed, apropos will return every man page whose description contains the specified text string: #apropos editThe above command will display a list of every man page whose description contains the text string "edit".apropos is helpful when you know what you want to do, but you're not certain of the appropriate utility or command to accomplish it.Practice Getting HelpThe following exercises will familiarize you with the various commands available for getting help including man, info, apropos, and --help. Practice working with man 1. In a terminal window, enter the following command: $man ls 2. Press Enter. Notice that one additional line of text is displayed. 3. Now press the space bar. Notice that an additional page of text is displayed. 4. Use the arrow keys to move up and down through the page. When you're finished, touch "q" to quit. 5. Enter the following command: $man 1 chmodWhat do you see in the upper left-hand corner of the screen? 6. Touch "q" to quit. 7. Enter the following command ("$" is part of the prompt): $man 2 chmodNotice in both the upper left and right-hand corners of the screen that the section number is displayed. 8. Touch "q" to quit the man page.
Practice working with the apropos utility

1. Start by entering the following command to see the man page for chmod: $man chmod
2. Read the description and notice that it includes the word "permissions".
3. Now, enter the following command: $apropos permissions
4. Notice in the output that chmod is listed, along with every other command whose description includes the word "permissions".Practice Working with infoNext, you'll use the info utility to view help for commands and learn how to navigate info pages by working through the first part of an "info" tutorial.

1. Enter the following command to see the info page for chmod: $info chmodThe info page for chmod opens.

2. Touch the "h" key to start a brief tutorial for info.3. Touch the "q" key when you're finished.Working with --helpThis exercise will show you how to use --help with GNU utilities.1. Enter the following command: $chmod --helpNotice that the help screen, albeit abbreviated, shows you the proper syntax for using the chmod command.

3. Enter the following command: $ls --helpNotice that the help screen fills more than one screen. Use the key combination of Shift-PageUp and Shift-PageDown to move up and down through the Terminal window.

No comments: