One of the essential reflexes every new Linux user must develop is the reflex to search for information when something’s amiss. But despite the fact that we live in a connected world, with search engines, wikis and huge quantities of information at our fingertips, it’s always good to have the info we need already installed on the system we’re working on. This makes for easy and fast access, and also for higher availability, should we lack access to an Internet connection. Besides, one can’t always trust what one finds on the Web, and the manual pages are available in a consistent form, ready to answer questions to the impatient. One of the design philosophies standing behind Unix, and by inheritance Linux as well, is that the system should be well documented. This is how man pages came into being. While all Unix-based OSs have man pages, there are differences between them, so what works on Linux might not work on Solaris, for example. There is an issue, though: the writing style of these pages is terse, minute, impatient to the newcomer, so you might want to read a manpage a few times until you get accustomed.
Frequently used options
- man -a keyword
display all available keyword manual pages in consecutive order
- man -f keyword
lookup and display a short description of any manual pages with reference to keyword
- man –warnings
- man -I …
enable case-sensitivity, as opposed to the default
- man -H[browser]
enable HTML output and view with browser, if defined, $BROWSER or the default defined at compile time (lynx usually)
Using the manpages
If you’re using most popular distributions, chances are you already have the manual pages installed, as part of the core system, together with essential bits like the shell or the init system. In order to grasp a finer and more detailed idea on how the manpages work, simply type
man man. And this is how one usually uses the manpages: if I, say, need to read the manpage for ls, I will type
man ls. It’s common courtesy to read the manual before asking questions on forums or IRC, and veterans will usually tell you off with a dry “RTFM” if you don’t. If you don’t know what that means, Google it. It’s part of the Linux/FOSS culture to read the manpage, then Google/use Wikipedia, and if neither of those yield results, ask the forums or other virtual social gathering media.
Since most of the manpages take more than just a page, man uses less as a pager so the text scrolls down one page at a time, for your reading convenience. Use PgUp and PgDown to scroll, or Space to scroll down, and Esc + V to scroll up. Of course, Up/Down scroll up or down one line at a time. ‘q’ at any time quits. The detailed use of less will be dealt with later, but at any time you can use
man less if you’re impatient. Searching inside the manpage is done, just as it’s done in vi/vim, with the slash (‘/’) key, and the next occurance of the search term can be accessed with ‘n’. If you know what you want, but not the exact name of the manpage,
apropos(1) is there to help. You probably noticed the number inside the parantheses after the command name. That specifies the category the command belongs to. Manpages are categorized for better organization and for avoiding duplicates. For instance, printf on a Linux system can belong to categories 1, 1p, 3, and 3p. It is both a C library function, but also a user command, part of coreutils and widely used in shell scripts. In Linux, categories suffixed with a ‘p’ are meant for POSIX programmers. In such cases, you can specify the desired category by inserting it between “man” and the command:
man 3 printf. Here are the categories, as seen on a modern Linux system.
- 1 – Executables and shell commands
- 2 – System calls
- 3 – Library calls
- 4 – Device files (usually stored in /dev)
- 5 – File formats
- 6 – Games
- 7 – Miscellaneous
- 8 – Sysadmin programs, usually accessible only to root and resident in /usr/sbin or /sbin
- 9 – Kernel routines
So, as you can see, the entire system is at your fingertips.
Like outlined before, the man system is inherited from the old Unix. GNU, on the other hand, came up with the info system, which serves the same purpose, but it introduces a nice facility, namely that you can use hypertext to jump from one page to another, just like you do when browsing the Web. Since OpenSolaris and the BSDs also use GNU software (gawk, gcc, emacs…), chances are those systems have some onfo pages available as well. Type
info info to get started.
1. Why do you think there is a separation between section 1 and section 1p, or 3 and 3p?
2. Do a little research and look up the category differences between Linux and the other free Unices.
3. What would you do if you would need to search for a manual page, but apropos wouldn’t be available? HINT: The man manpage
4. Find another command that belongs in more than one category.
|Learning Linux man command with examples|
|Linux command syntax||Linux command description|
man -t command | lpr -Pps
|Generate using troff or groff format and pipe to the printer named ps|
man -l -Tdvi command.1x.gz > command.1x.dvi
|generate dvi (device independent) output, usually for using further with tools like dvips|
man -C file
|Use file as the config file instead of the default|