5

I am thinking about the man page sections 1 = user commands, 2 = system calls etc.

Is there a way, a command that will tell me what sections are available to read besides running something like man 1 gedit, man 2 gedit, man 3 gedit etc?

3

One option:

apropos fork

to limit to exact word:

apropos -e fork

Alternatively, as apropos uses regex by default:

apropos "^fork$"

Alternatively use man -k instead of apropos.

Check out man pages for apropos and man for more details.

  • BTW, if you are using Cygwin, you may not find much output with man -k. – smwikipedia 2 days ago
5

With the man from man-db at least:

$ man -f open
open (2)             - open and possibly create a file
open (1)             - start a program on a new virtual terminal (VT).
open (3tcl)          - Open a file-based or command pipeline channel
open (3perl)         - perl pragma to set default PerlIO layers for input and output

Same as:

$ whatis open
open (2)             - open and possibly create a file
open (1)             - start a program on a new virtual terminal (VT).
open (3tcl)          - Open a file-based or command pipeline channel
open (3perl)         - perl pragma to set default PerlIO layers for input and output

Or to get the paths of the man pages:

$ man -wa open
/usr/share/man/man1/openvt.1.gz
/usr/share/man/man3/open.3tcl.gz
/usr/share/man/man2/open.2.gz
/usr/share/man/man3/open.3perl.gz

To read all the man pages on a given topic, man -a is very common.

Note however that some implementations run one instance of the pager for each man page (you need to quit the pager to get to the next man page and there's no coming back), while some others pass the man pages as separate arguments to a single pager invocation (and you use :n, :p for instance with the less pager to navigate through the pages).

2

If you're man is from the "man-db" package, you can invoke this to see the "intro" page for each section of the manual:

man -a intro

If you know the location of the man pages database, this will list all of the section directories (man1, man2, man3, etc):

(cd /usr/share/man; ls -d man*)

Also if using man from the man-db package, you can see the location of the man pages database(s) by invoking man -w (this option also exists on FreeBSD man, but I don't have it installed so I don't know if it gives the same output). For example, on Debian 8 (jessie):

$ man -w
/usr/local/man:/usr/local/share/man:/usr/share/man

Using man -w, a simple script to list all of the section numbers available in all of the man database directories would be:

#!/bin/sh
IFS=":$IFS"
for i in $(man -w)
do
    (
        cd "$i"
        for j in man*
        do
            if [ -d "$j" ]
            then
                echo "${j#man}"
            fi
        done
    )
done | sort -u
2

I use my package manager to do this kind of stuff.

On Archlinux:

pacman -Ql gedit | grep /man/

RH/Fedora:

dnf repoquery -l gedit | grep /man/

Debian/Ubuntu/...

dpkg-query -L gedit | grep /man/
1

The following command should list all available man page sections for a given command:

find /usr/share/man -name "<command>.*.gz" | egrep -o '[0-9]' | sort -u

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.