posts about

Using the man pages wisely

January 20, 2021.

Here are some tips to use man pages wisely.

1. man returns the first match

man, by default, searches all sections in predefined order and returns the first page found. However, this might not always be the one I am looking for.

Take crontab page as an example.

$ man crontab

This returns the page from section 1 (shell commands).

If I am rather interested in the crontab file format instead of executable command, I need to refine my search. Provide section argument to make the search in section 5 (file formats).

$ man 5 crontab

Furthermore, it helps to see which sections a page reside in with a short description the page is about.

2. Search the man database by keyword

man, by default, performs the search by checking the page names. This is not flexible. I might be interested in the pages that contain some keyword of interest.

As an example, if I am interested in commands for controlling wireless devices

$ man -k wireless

-k option prints pages that contain wireless word in the short description or name.

This option supports regex matches. To list pages which contain wireless or bluetooth keyword

$ man -k "wireless|bluetooth"

3. Be aware of conventional section names

Not only SYNOPSIS or DESCRIPTION, there are other sections that I find useful.

SEE ALSO shows pages related to the current one. It helps to find useful information or discover new commands.

ENVIRONMENT describes environment variables that accommodate with the command and shows me how I can control command behavior.

comments powered by Disqus Send feedback to me @karakays_.


← Ask vim for help  How to open files from command line? →