Technical skill

Linux command: man

Find instructions for a command

Suppose you have heard of the ls command but do not know what its options do. The man command opens a local reference page for software installed on the system, usually in a pager, a program that lets you read a long page a screen at a time. The general form is man command, where command is the name of the page you want. For example, man ls opens the manual page for ls. Manual pages cover commands, programming interfaces, file formats, and other system topics.

man ls

Pages are grouped into numbered sections. Section 1 covers user commands, 2 system calls, 3 library functions, 5 file formats and configuration, 7 conventions and overviews, and 8 system-management commands. The same name can appear in several sections. printf may refer to a shell command or a C library function, so select the page with man 1 printf or man 3 printf:

man 1 printf
man 3 printf

Similarly, man 5 passwd describes the passwd file format, not a command with the same name. The number chooses a section; it is not part of the page name.

When you do not know a page name, man -k keyword searches page names and their short descriptions. On man-db systems, apropos keyword performs the same kind of search. For example:

man -k archive

This searches the index, not every line of every manual page. Results may be incomplete if the local index is missing or out of date. man -f printf asks for a one-line description, as does whatis on systems that provide it. Check man man for options supported by the local implementation.

A page often has sections named NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXAMPLES, and SEE ALSO. The synopsis shows accepted command forms. Brackets mark optional syntax; an ellipsis usually means an argument can repeat. These are notation conventions, not text to type. Read the relevant option and compare its example with your task. A local page may describe the installed version more accurately than a manual for another release.

The pager comes from system configuration or the environment. In less, press q to exit, /word to search forward, and n to move to the next match. Another pager may use different keys. If a topic is unavailable, its documentation package may not be installed, or the information may be under another section or in a separate project guide.

For an unfamiliar option, choose the page section that matches the subject, read the synopsis, then inspect the option and examples. man -k archive can find likely page names when you do not know the command; treat a keyword result as a starting point and verify the page before using its command.

Interactive exercises

Materials

Skillsets
Skillset Skyeng Senior PlatOps preview
image descriptionSkyeng Senior PlatOps
by Artem Naumenko (slack2)
7 users
Skillset Linux administrator preview
image descriptionLinux administrator
by Infinite Education
3080 users
Skillset Devops preview
image descriptionDevops
by Ajay Kumar
2004 users
Skillset Linux for backend developer preview
image descriptionLinux for backend developer
by Artem Naumenko (fb)
16 users
Skillset Skyeng SRE preview
image descriptionSkyeng SRE
by Yuliya Marochkina
12 users
Skillset Skyeng linux system administrator preview
image descriptionSkyeng linux system administrator
by Vitaliy Okulov
3 users
Skillset Devops preview
image descriptionDevops
by Dio
3 users
Skillset Skyeng Ops (for DevOps) preview
image descriptionSkyeng Ops (for DevOps)
by Roman Burnashev
2 users
Do you know that ...?
Any useful or interesting facts about the skill. Any peace of information would be useful