Skip to main content

LFCS Certification Course

Chapter #12: How to Use man, info, and help Commands in Linux

In this chapter, you'll learn how to use man pages, --help, info, and offline docs to master Linux tools and pass the LFCS exam without internet access.

Once you get used to working with the command line and feel comfortable doing so, you realize that a regular Linux installation includes all the documentation you need to use and configure the system.

Another good reason to become familiar with command line help tools is that in the LFCS exam, those are the only sources of information you can use - no internet browsing and no googling. It’s just you and the command line.

For that reason, in this chapter, we will give you some tips to effectively use the installed docs and tools in order to prepare to pass the Linux Foundation Certification exams.

Man Pages

A man page, short for manual page, is nothing less and nothing more than what the word suggests: a manual for a given tool that contains the list of options (with explanation) that the command supports, and some man pages even include usage examples as well.

To open a man page, use the man command followed by the name of the tool you want to learn more about. For example:

man diff

Will open the manual page for diff, a tool used to compare text files line by line (to exit, simply hit the q key).

Compare Text Files in Linux with diff Command

Let’s say we want to compare two text files named file1 and file2. These files contain the list of packages that are installed in two Linux boxes with the same distribution and version.

Doing a diff between file1 and file2 will tell us if there is a difference between those lists:

diff file1 file2
Compare Text Files in Linux with diff Command

Where the < sign indicates lines missing in file2. If there were lines missing in file1, they would be indicated by the > sign instead.

On the other hand, 7d6 means line #7 in file1 should be deleted in order to match file2 (same with 24d22 and 41d38), and 65,67d61 tells us we need to remove lines 65 through 67 in file one. If we make these corrections, both files will then be identical.

Compare Files Side by Side in Linux

Alternatively, you can display both files side by side using the -y option, according to the man page. You may find this helpful to more easily identify missing lines in files:

diff -y file1 file2
For a more compact comparison, combine -y with --suppress-common-lines to show only the differences side by side.
Compare Files Side by Side in Linux

Also, you can use diff to compare two binary files. If they are identical, diff will exit silently without output. Otherwise, it will return the following message: β€œBinary files X and Y differ”.

The --help Option