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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI 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?
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.
man -k
.
– smwikipedia
Jul 22 '19 at 1:29
man fork
, I see a man page for the syscall fork
(manpage FORK(2)
). If I use apropos "^fork$"
, I get nothing appropriate
. If I use apropos fork
, I get a listing with commands like pearlfork(1)
, spfd(1)
and others, but not exaclty fork
. By the way, I came to this answer trying to listman pages for cc
, and I was having the same results (getting a man page for man cc
, but not listing any man pages for exactly cc
with man -k cc
). Btw, I'm on Mac OS X, not sure if it is relevant.
– Rafael Eyng
Jan 5 '20 at 13:31
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).
man -wa open
was the only useful one in Mac OS X. How to open an specific man page, though? I mean, I know I can do man 3 open
, but how to diferentiate between /usr/share/man/man3/open.3tcl.gz
and /usr/share/man/man3/open.3perl.gz
in your example? And why does it even make sense to have two entries for man 3 open
?
– Rafael Eyng
Jan 5 '20 at 13:36
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
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/
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