Docu review done: Thu 29 Jun 2023 12:34:38 CEST
Table of Content
General
man
is the system’s manual pager. Each page argument given to man
is normally the name of a program, utility or function. The manual page associated with each
of these arguments is then found and displayed. A section, if provided, will direct man
to look only in that section of the manual. The default action is to
search in all of the available sections following a pre-defined order (see DEFAULTS), and to show only the first page found, even if page exists in several sec‐
tions.
The table below shows the section numbers of the manual followed by the types of pages they contain.
Section | Type |
---|---|
1 | Executable programs or shell commands |
2 | System calls (functions provided by the kernel) |
3 | Library calls (functions within program libraries) |
4 | Special files (usually found in /dev) |
5 | File formats and conventions, e.g. /etc/passwd |
6 | Games |
7 | Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7), man-pages(7) |
8 | System administration commands (usually only for root) |
9 | Kernel routines [Non standard] |
A manual page consists of several sections.
Conventional section names include NAME, SYNOPSIS, CONFIGURATION, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, ENVIRONMENT, FILES, VERSIONS, CONFORMING TO, NOTES, BUGS, EXAMPLE, AUTHORS, and SEE ALSO.
The following conventions apply to the SYNOPSIS section and can be used as a guide in other sections.
Convention | Description |
---|---|
bold text | type exactly as shown. |
italic text | replace with appropriate argument. |
[-abc] | any or all arguments within [ ] are optional. |
-a |-b | options delimited by |
argument … | argument is repeatable. |
[expression] … | entire expression within [ ] is repeatable. |
Exact rendering may vary depending on the output device. For instance, man will usually not be able to render italics when running in a terminal, and will typically use underlined or coloured text instead.
The command or function illustration is a pattern that should match all possible invocations. In some cases it is advisable to illustrate several exclusive invocations as is shown in the SYNOPSIS section of this manual page.
SYNOPSIS
man [man options] [[section] page ...] ...
man -k [apropos options] regexp ...
man -K [man options] [section] term ...
man -f [whatis options] page ...
man -l [man options] file ...
man -w|-W [man options] page ...
Daily Commands
Search in all man pages
Search for text in all manual pages. This is a brute-force search, and is likely to take some time; if you can, you should specify a section to reduce the number of pages that need to be searched. Search terms may be simple strings (the default), or regular expressions if the –regex option is used.
Note that this searches the sources of the manual pages, not the rendered text, and so may include false positives due to things like comments in source files. Searching the rendered text would be much slower.
Hint:
It will open the first match directly, but it can be that it found others as well, which it does not tell you right in front. Only if you close the first man page, which you have on your screen, it could display something like this:
The command is executed like shown above in the general section man -K <searchterm>
After you have closed the first matching man page, it can be that you get something like this displayed:
--Man-- next: systemd.resource-control(5) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
Now you know, there is at least 1 more man page which contains the term you searched for.
Continue with pressing the right keys.
The downside is, you dont know how much it found in total and you can not see all matching man
page files at once.
Search for command
Equivalent to
apropos
Lets assume you are running the first time a new system and you recogniced that the commands are a bit different then what you are used to.
There man -k searchterm
kicks in and can help you.
This command parses all shot descriptions and man
page names with the keyword/regex you added next to it.
$ man -k "(run|exec).*user"
applygnupgdefaults (8) - Run gpgconf --apply-defaults for all users.
lxc-usernsexec (1) - Run a task as root in a new user namespace.
pkexec (1) - Execute a command as another user
runuser (1) - run a command with substitute user and group ID
su (1) - run a command with substitute user and group ID
sudo (8) - execute a command as another user
sudoedit (8) - execute a command as another user
Colouing man pages
To color man pages there is an easy trick to do so and makes it way easier to read them.
It depends on the installed groff version.
Before version 1.23.0
Add one of the below snippets to your sourced rc files for your profile/shell or source a new file
Using printf
:
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
Using tput
:
man() {
env \
LESS_TERMCAP_mb=$(tput bold; tput setaf 1) \
LESS_TERMCAP_md=$(tput bold; tput setaf 1) \
LESS_TERMCAP_me=$(tput sgr0) \
LESS_TERMCAP_se=$(tput sgr0) \
LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4) \
LESS_TERMCAP_ue=$(tput sgr0) \
LESS_TERMCAP_us=$(tput bold; tput setaf 2) \
man "$@"
}
Version 1.23.0 and above
If you have groff(-base) with version 1.23.0 or higher installed then you need to set one of the ablow menitoned variables, otherwiese the coloring won’t work any more.
GROFF_NO_SGR
with the vaule1
MANROFFOPT
with the vaule-c
Both variables will work with both snippets
Using printf
:
man() {
env \
MANROFFOPT="-c" \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
Using tput
:
man() {
env \
GROFF_NO_SGR=1 \
LESS_TERMCAP_mb=$(tput bold; tput setaf 1) \
LESS_TERMCAP_md=$(tput bold; tput setaf 1) \
LESS_TERMCAP_me=$(tput sgr0) \
LESS_TERMCAP_se=$(tput sgr0) \
LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4) \
LESS_TERMCAP_ue=$(tput sgr0) \
LESS_TERMCAP_us=$(tput bold; tput setaf 2) \
man "$@"
}
from man grotty
-c Use grotty’s legacy output format (see subsection “Legacy output format” above). SGR and OSC escape sequences are not emitted. GROFF_NO_SGR If set, grotty’s legacy output format is used just as if the -c option were specified; see subsection “Legacy output format” above.
Details can be found here: