How to find out what a Linux command does
Linux distributions contain three powerful sets of documentation to enable users and administrators to get the most out of the system. Knowing how to use these resources effectively is an essential skill for Linux users.
Here are the three documentation sets:
- Man pages
- Info pages
The man pages
Man pages are the go-to resource for nearly every Linux user working at the command line.
What can you discover via the man pages?
- The command's summary
- Options and explanations
- Author and maintainer
This is perfect for when you cannot recall less commonly used options or work on multiple operating system platforms daily (the options between Linux and Unix versions of commands often differ).
Using the man pages is straightforward; simply type the
man command and include the command you need more information about. For example, to display the manual for the
ls command, type
Man pages include a powerful set of search capabilities to help you find exactly what you need. Once the man page is displayed, type a forward slash (/) to enable keyword searching. Simply enter the word you're looking for after the slash and select Enter. Use the n and N keys to find the next or previous example of the keyword. Use Ctrl+C to end the search.
Man pages are organized into the following sections:
- User commands (section 1)
- System calls (section 2)
- C library functions (section 3)
- Devices and special files (section 4)
- File formats and conventions (section 5)
- Games (section 6)
- Miscellanea (section 7)
- System administration tools and daemons (section 8)
Typically, a request for a man page goes to section 1 or 8, but you can specify the section (assuming the requested command exists in multiple sections) by typing:
$ man 1 ls
Comfort with accessing man pages and defining keyword searches is an essential Linux user skill. In fact, system documentation in general, and man pages specifically, are called out in the Red Hat Certified System Administrator (RHCSA) exam objectives.
[ See how your operating system is the foundation that solidifies and unifies your IT infrastructure in Why the operating system matters. ]
The info command
The info pages play a similar role to man pages, though they tend to be a little more user-friendly. The man pages are basically a short, terse reference, while info pages tend more toward readability and deeper explanations. The info page system also supports basic linking between documents for easier cross-referencing. This provides a more structured and readable documentation set.
The syntax for info pages is the same as with
$ info ls
More formal documentation, along with templates, tutorials, licenses, and some configuration files, is found at
/usr/share/doc. The files provide significantly more detail than man pages. These package-specific files are usually compressed, but tools such as
less handle the content seamlessly.
[ Learn more about Linux in the free training course Red Hat Enterprise Linux Technical Overview. ]
You can see what documentation is available by typing:
$ ls /usr/share/docs | less
Each package has its own subdirectory. Run the following command to see the documentation for the Nano text editor:
$ ls /usr/share/doc/nano
To help you practice using these resources, I've included three simple challenges involving the Nano text editor (so make sure Nano is installed before accomplishing these). The answer key is at the end of the article if you need it.
- How do you remove the two help lines at the bottom of Nano?
- Find the Nano bug tracker URL.
- What is the "wonderfully easy-to-use and friendly text editor" that Nano is based on?
Not all systems are internet-connected, and not all reminders need to come from advanced Google searches. Sometimes all a sysadmin needs is a quick hint, "Oh yeah, that's the option for long format." Man pages are great for those short prompts. Info pages add more detail, better linking between resources, and more readability. The official documentation stored at
/usr/share/doc provides the most depth, examples, templates, license information, and other relevant resources.
- pico (Pine composer)