I feel man is one of the frequently used command along ls and cd commands in Linux. Have some more which you think we use frequently then post it in comments. Many people who are new to Linux do not know it’s potential. They just read a man page for a specific command and go away or just use “man command”. This post is mainly meant for newbies to Linux/Unix. Do you know there are other commands which are similar to man command? Below are the list of commands which I call cousins to man pages.
Other helpful manuals available in Linux
To know more about these commands you should visit my other post on them.
As I said man(abbreviation to manual) command is useful to read more details about any command you want.
Example 1: Get information about passwd command such as what it do, options available, examples to use it, related commands etc.
This will be opened in a default file viewer, most of the Linux distributions use less as default editor. To exit from man pages use “q”.
Example 2: As I said man pages are opened in a default viewer, if you want to change that use -P to change to some other viewer. Below example uses cat command for viewing man pages.
man -P cat passwd
Example 3: How about reading man with man pages. We can do that with following command.
This post is about details displayed from above command(man man) output.
Example 4: There is a perception that man pages are written only for Linux command. That is not true. We have man pages written for normal commands, admin commands, configuration files, concepts etc. Below is the list of man categories.
Man pages types in Linux
1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8 System administration commands (usually only for root) 9 Kernel routines [Non standard]
If you see there are total 9 type of man pages available. This number varies on different flavours of Linux/Unix. What that means for you? Let me explain with an example.
Suppose you want to know more about passwd command in Linux we just give man passwd. But if you want to learn more about /etc/passwd file format then you have to use man 5 passwd. Both command outputs are different, see it your self by using below examples.
man <catagory-number> <keyword>
man 1ssl passwd
man 5 passwd
All above commands will give you different information depending on category where they fall.
Where are my man pages located?
Example 5: All the man pages are located in /usr/share/man. If you want to know where a perticular man page located use whereis commnad
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz /usr/share/man/man1/passwd.1ssl.gz
If you observe output, we have different man pages(man5, man1, man1) located in different locations. These corsponds to man page types which we seen in above example.
Example 6: Not liking all the man pages in short and bit confused about the output, use -w for finding location of a man page.
man -w <type> command
surendra@sanne-taggle:~$ man -w 5 passwd /usr/share/man/man5/passwd.5.gz
Example 7: Want to display all these commands in single command instead of using man 1, man 5 etc? Use -a for that.
man -a passwd
Example 8: How about viewing multiple man pages for different commands at same time. You can use man command to append commands.
man ls pwd whoami
The Linux man page categories
Each man page is categorised in to different sections for easy use. Suppose if you want just basic options use first section or if you want learn about each option in detail use second section.
Below are the common categories(not necessary all or in the same order) we see in most of the man pages.
NAME -One line answer about what this command do. This is the same output we see in whatis command output.
SYNOPSIS – Gives syntax and what available options for a given command
DESCRIPTION -A brief intro about the command
OPTIONS -Shows one or two lines description for each option that command have
CAVEATS -a warning or proviso of specific stipulations, conditions, or limitations.
FILES -Files associated with this command.
EXIT VALUES -Exit values when executing this command.
AUTHOR -Who written this command
REPORTING BUGS -Preferred communication to author for reporting bugs.
COPYRIGHT -What copyrights this command provided
SEE ALSO -Similar commands to this one.
Other man page command examples
Example 9: Display short description of each keyword in a given name. Suppose you want to see all the passwd keyword based man pages use below command.
man -f passwd
surendra@sanne-taggle:~$ man -f passwd passwd (5) - the password file passwd (1) - change user password passwd (1ssl) - compute password hashes
This output is similar to apropos command.
Example 10: Not satisfied with just command names? If you want to search entire man pages installed for a specific key word use below command.
man -k passwd
surendra@sanne-taggle:~$ man -k passwd chgpasswd (8) - update group passwords in batch mode chpasswd (8) - update passwords in batch mode fgetpwent_r (3) - get passwd file entry reentrantly getpwent_r (3) - get passwd file entry reentrantly gpasswd (1) - administer /etc/group and /etc/gshadow grub-mkpasswd-pbkdf2 (1) - generate hashed password for GRUB htpasswd (1) - Manage user files for basic authentication pam_localuser (8) - require users to be listed in /etc/passwd passwd (1) - change user password passwd (1ssl) - compute password hashes passwd (5) - the password file passwd2des (3) - RFS password encryption smbpasswd (5) - The Samba encrypted password file smbpasswd (8) - change a user's SMB password update-passwd (8) - safely update /etc/passwd, /etc/shadow and /etc/group
-k is a kind of regular expression which search every where in man pages.
Example 11: Save man pages to a file so that we can view them in future.
man -P cat passwd > passwd_man_page.txt
Example 12: Do you want to search man pages without case sensitive. Use -i for that.
man -ki passwd
This will ignore all the case sensitive stuff.
Latest posts by Surendra Anne (see all)
- Online training on Linux Bash shell scripting - February 8, 2018
- 15 iostat command examples in Linux/Unix - December 4, 2017
- How to Installing and Configuring Firewalld on Linux - November 29, 2017
- 4 sleep command examples in Linux/Unix - November 2, 2017
- 5 SSH alias examples in Linux - October 16, 2017