3.3 Man Pages

Linux comes built in with a whole range of manual pages on three very important locations.

  • The man command mostly known as the man pages

  • Documentation folder /usr/share/doc

  • And the command help interface--help or -h.

Man pages

Here is an online browser version of the man pages in Linux: https://linux.die.net/man/

The man pages can be used with any other command as well as much more in depth information. Let’s go through some examples:

man find

This will put you in the manual page for the find command. You can navigate the man page with the arrow keys page-up and page-down, and see what all the options are or use / to search for keywords. Press q to Quit. Very important cheat key combination is shift-G; this takes you to the bottom of the file and you can check the examples.

When you forgot something you can search all man pages for key words to research or figure somethings out. We can use the man -k option.

man -k lvm

Result should look similiar to this:

[fons@rhcsa media]$ man -k lvm
lvm (8)              - LVM2 tools
lvm-config (8)       - Display and manipulate configuration information
lvm-dumpconfig (8)   - Display and manipulate configuration information
lvm-fullreport (8)   - (unknown subject)
lvm-lvpoll (8)       - (unknown subject)
lvm.conf (5)         - Configuration file for LVM2
lvm2-activation-generator (8) - generator for systemd units to activate LVM volumes on boot
lvmcache (7)         - LVM caching
lvmconfig (8)        - Display and manipulate configuration information
lvmdiskscan (8)      - List devices that may be used as physical volumes
lvmdump (8)          - create lvm2 information dumps for diagnostic purposes
lvmpolld (8)         - LVM poll daemon
lvmraid (7)          - LVM RAID
lvmreport (7)        - LVM reporting and related features
lvmsadc (8)          - LVM system activity data collector
lvmsar (8)           - LVM system activity reporter
lvmsystemid (7)      - LVM system ID
lvmthin (7)          - LVM thin provisioning
lvmvdo (7)           - EXPERIMENTAL LVM Virtual Data Optimizer support
perlvms (1)          - VMS-specific documentation for Perl
pvcreate (8)         - Initialize physical volume(s) for use by LVM
pvremove (8)         - Remove LVM label(s) from physical volume(s)

This just listed all the information connected to lvm. This is a method of managing disks and disk space. More on that later. You can see numberings with manual files; these are their section numbers. All manual pages are devided using this system.

Section

Topic

1

Commands available to users

2

Unix and C system calls

3

C library routines for C programs

4

Special file names

5

File formats and conventions for files used by Unix

6

Games

7

Word processing packages

8

System administration commands and procedures

So if we want all the manual pages for the the System Administrator Commands and Procedures we can do:

man -k lvm | grep 8
[fons@rhcsa]$ man -k lvm | grep 8
lvm (8)              - LVM2 tools
lvm-config (8)       - Display and manipulate configuration information
lvm-dumpconfig (8)   - Display and manipulate configuration information
lvm-fullreport (8)   - (unknown subject)
lvm-lvpoll (8)       - (unknown subject)
lvm2-activation-generator (8) - generator for systemd units to activate LVM volumes on boot
lvmconfig (8)        - Display and manipulate configuration information
lvmdiskscan (8)      - List devices that may be used as physical volumes
lvmdump (8)          - create lvm2 information dumps for diagnostic purposes
lvmpolld (8)         - LVM poll daemon
lvmsadc (8)          - LVM system activity data collector
lvmsar (8)           - LVM system activity reporter
pvcreate (8)         - Initialize physical volume(s) for use by LVM
pvremove (8)         - Remove LVM label(s) from physical volume(s)

And now we only got the result for section 8 manuals.

Sometimes when new commands are installed, the manual database is not updated immediately and so you will not be able to find the correct man pages. Running the mandb command without any input will update the manual database for you, making whatever manuals you couldn’t find available for you if present at all.

mandb

You can run the command now as root. You should see results of adding and removing things to the database.

/usr/share/doc

This directory holds all the documentation provided by the software and Linux itself.

Let’s check the documentation of bash-completion:

/usr/share/doc/bash-completion

Let’s check the contents:

ls -l

Or the alias

ll

The contents are expected to look like this:

[root@rhcsa bash-completion]# ll
total 120
-rw-r--r--. 1 root root   302 Apr 27  2017 AUTHORS
-rw-r--r--. 1 root root 86473 Jul  1  2017 CHANGES
-rw-r--r--. 1 root root  7055 Apr 27  2017 CONTRIBUTING.md
-rw-r--r--. 1 root root 13944 May 11  2019 README.md
-rw-r--r--. 1 root root  2874 Jul  1  2017 bash_completion.txt

Here you can read about the Bash completion and changes and such. If you get stuck, or want to know more, you can get information here

--help

Nearly all commands in Linux have a --help or -h to show you the basic functions of an command. Let’s see how some of this works.

Type the following command:

find --help

It will look like this.

[root@rhcsa ~]# find --help
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:

operators (decreasing precedence; -and is implicit where no others are given):
      ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
      EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2

positional options (always true): -daystart -follow -regextype

normal options (always true, specified before other expressions):
      -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
      --version -xautofs -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
      -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
      -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
      -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
      -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN
      -readable -writable -executable
      -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
      -used N -user NAME -xtype [bcdpfls]
      -context CONTEXT


actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print 
      -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
      -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
      -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

Report (and track progress on fixing) bugs via the findutils bug-reporting
page at http://savannah.gnu.org/ or, if you have no web access, by sending
email to <bug-findutils@gnu.org>.

So let’s say you want to find files by size and you do now know how; by using find --help we see the -size switch. And now we know how to perform this search by size. Let’s check the man page for more information.

man find

In here press / to search and type size press enter and you are at the section on size searches.

Let’s try to look for a file that is larger then 100 Megabyte.

find / -size +100M
[root@rhcsa ~]# find / -size +100M
/proc/kcore
find: '/proc/28358/task/28358/fd/5': No such file or directory
find: '/proc/28358/task/28358/fdinfo/5': No such file or directory
find: '/proc/28358/fd/6': No such file or directory
find: '/proc/28358/fdinfo/6': No such file or directory
/usr/lib64/firefox/libxul.so

So that are some results. In actuality, there are only 2 results. Let’s clean up the result by removing the error messages.

find / -size +100M 2>/dev/null

The result should now look as following:

[root@rhcsa ~]# find / -size +100M 2> /dev/null
/proc/kcore
/usr/lib64/firefox/libxul.so

So what did we add here?
We added 2> /dev/null. With that, we did a redirect > on stream 2 to a file location called /dev/null. This is a location on the disk that does not really exist hardware wise, which basicly means it’s a data based black hole. The error output got picked up and send to nowhere.

We can check the actual size of the file with the command:

du -h /usr/lib64/firefox/libxul.so

Result:

[root@rhcsa ~]# du -h /usr/lib64/firefox/libxul.so
201M  /usr/lib64/firefox/libxul.so

Awsome we figured it out! +10 skill points