Showing posts with label man. Show all posts
Showing posts with label man. Show all posts

Thursday, August 6, 2009

Printing manuals

The command man is very useful, however what if we want to move the content to the paper. The col is our friend here. To change every manual page into normal printable text file we type:

$ man ls | col -b > manls.txt

What happened here? The command col filters reverse line feeds and replaces white-space characters with tabs. We can now print manls.txt or go one step further. Using groff formating system and ps2pdf, which converts postscript files into pdf we can convert any manual to PDF file:

$ man ls | col -b | groff -Tps -fC | ps2pdf - > manls.pdf

This command passes our txt formatted manual into groff which converts it to postscript (-Tps), additionally we choose the courier font family as default (-fC, -fT is Times New Roman, -fA is Arial), because it looks better. In the end ps output is passed to ps2pdf which converts it to pdf and everything is put into manls.pdf file.
We can of course convert other files this way. Man is only an example.

Wednesday, August 5, 2009

One man and friends

Linux has a lot of commands and that's why it can look scary at the beginning. What you really need is to know how and where to look for help. There are several commands that can help us:

man,
info,
pinfo,
whatis ( = man -f),
apropos ( = man -k),

man gives you the description of every command (unless it doesn't have the manual). If you want to find out about man, type:

$ man man

Sometimes there are more than one manual for specific command. If we want to get to the exact manual page we type:

man <man page> <command>

getopt is good example of this. The man page 1 describes the C language function , whereas page 3 describes bash shell command.

info is an interactive help system, where you can navigate through. You can type just info
to get the full manual or type info info to get the information on info command. There is one more command called pinfo, which gives you the same as info, however it's more colourful and based on lynx-like (console webbrowser) menu. You can cycle through info pages with n and p. Quit with q.

whatis is really useful and allows us to get short description of linux commands. This is what we can find out about ls command:

$ whatis ls

ls (1) - list directory contents
ls (1p) - list directory contents

By the way the same effect we can be achievied using man -f.

Another useful command is apropos. It looks for text strings inside whatis database. Typing:

$ apropos man

gives us all the commands and their descriptions containing 'man' string somewhere inside. The same effect gives us man -k command.

To see what the commands in /bin/ directory do we type:

$ whatis $(ls /bin) | grep -v aprioprate