Linux provides many ways to access documentation for other commands! Before we had the ability to use search engines to look up any questions we had, offline documentation was our only point of reference.
We can access documentation in the terminal itself using these files and commands:
- The
/usr/share/doc/
directory - The
man
command - The
info
command
/usr/share/doc/
The /usr/share/doc/
directory contains README files, simple text files that describe a program, for many installed packages in your Linux distribution. You can explore the documentation available there using the command below.
ls /usr/share/doc
The man
command
The man
command is used to access the manual pages, the traditional way of distributing documentation for all bash programs. The command
man [options] <command_name>
will give us the command’s manual page includes a brief synopsis of the program, a description that lists all options, and examples.
For example, man cat
will display the manual page for the command cat
. The manual pages can be rather long but don’t be alarmed. We can also browse the manual pages online.
The info
command
Even though manual pages are somewhat outdated, they make for great cheat sheets/reference cards. For full and detailed documentation, we can use the info
command which also contains more recent information about programs than man
. Its basic usage is:
info [options] <command_name>
For example, running info cat
in the terminal will provide detailed information about the command cat
.
Instructions
Use ls
to see inside the directory /usr/share/doc/
.
Each one of the directories you see includes READMEs, examples, changelog, and more for their respective programs.
Open up the man page for the command ls
. You can exit the man page at any time by pressing the q key.
We can scroll through the man page with the up and down arrow keys. To search a string, we can type /
followed by the search text and press the Enter. We can step through the results with the n key.
When you quit out of the manual page, press Enter into a new line to complete this checkpoint!
Open up the man page for the command man
itself. The manual page for the man
command is a good place for a beginner to start getting familiar with manual pages. When you’re ready, press q to close the manual page.
You might have noticed the MAN(1)
in the upper corners of the manual page. The number in the parenthesis refers to the manual section. Section 1
refers to general commands, 2
refers to system calls, and so on.
When you quit out of the manual page, press Enter into a new line to complete this checkpoint!
Open up the info
page for the command ls
. Notice the stark difference in detail between the manual page and the info page.
The controls to browse the info pages are very similar to the manual page except you can press enter when the marker is over an underlined section to jump straight to that section. When you’re ready, press q to close the page.
When you quit out of the info
page, press Enter into a new line to complete this checkpoint!