Quick access to system help with Linux shell commands (I) [man pages definition Specification]


As friends who have just learned Linux, we get a command and don’t know how to use it. Generally, we will first look at the description of the default parameters of the command, and then we don’t know. We can refer to the manual through the man command. Still can’t find a way, search on the Internet, and finally go to the big forum to post. Because it takes a long time to post, someone replies. Over time, the enthusiasm for learning Linux has been neglected. In fact, this is also the biggest difficulty in learning Linux.

There are generally two kinds of Linux command help. The command code contains help instructions. This kind of help is usually very concise and too long. The size of the program itself and daily maintenance are inconvenient. There is also a help file, which is similar to the CHM format file of windows. Let me talk about how to check these two kinds.

1、 Program intrinsic help information

For example:

[[email protected] ~]$ cat --help
Usage: cat [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output.
  -A, --show-all           equivalent to -vET
#... omitted
[[email protected] ~]$ man -h
man, version 1.6d
usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
        [-m system] [-p string] name ...
#... omitted

The above two examples obtain command help through parameters, which we often use. Say something off the topic and start to get off the topic… Ha ha

I want to talk about the common parameter rules of commands. Generally, if the parameter is one character, use: one “-” connect. If the subsequent parameter is multiple characters, use: “” — “connect. Is it one” – “can’t be followed by multiple characters? This is the flexibility of Linux command analysis. If you use multiple characters as one”- “Connection, it will divide it into multiple parameters. For example, LS – Al is equivalent to LS – a – L. if you use: LS – – Al, it will take Al as the overall parameter.
It should also be noted that generally, linux commands will use – H or — help as the return command line help information. Especially — help is the most. Some commands support both. This has become a habit. If you encounter a command you can’t use, you might as well try these two parameters.

2、 Get command external help file (man pages)

What are man pages

Under windows, we often call the help manual e-book, which is a CHM file. The help manual under Linux is generally called man pages. They are stored in some Linux folders according to certain rules. If you need to consult them, you can consult them through the index command in the man pages manual. The common ones are: info, man (mainly talked about in this article), xman, etc. Speaking of this, some friends will say: is CHM under Windows convenient? How about search, query and expression? Check on the shell terminal to see if it is a large text, boring and dense. Ha ha, what I can say is that its content performance is also very rich. It supports ordinary text, tables, pictures, and search and locate the information needed. It must be several times faster than clicking through the mouse in windows.

So why is it easy to manage and fast to index. Next, let’s take a look at the specification of man pages.

Man pages directory and file name specification definition
Storage directory:

The first is the directory and storage specifications. Linux documents are often placed in the directory specified by the manpath environment variable. It is usually in the directory: / usr / share / man. The following structure of this directory is also defined:

[[email protected] man]$ ls
bg  el  fr            hu            it.UTF-8  man1   man2x  man4   man6   man8   manl  pl.ISO8859-2  ro         sk  zh_CN
cs  en  fr.ISO8859-1  id            ja        man1p  man3   man4x  man6x  man8x  mann  pl.UTF-8      ru         sl  zh_TW
da  es  fr.UTF-8      it            ko        man1x  man3p  man5   man7   man9   nl    pt            ru.KOI8-R  sv
de  fi  hr            it.ISO8859-1  man0p     man2   man3x  man5x  man7x  man9x  pl    pt_BR         ru.UTF-8   tr
#It can be divided into two types: man [*] directory and en, zh_ Cn, pl. iso8859-2 represents language region and coding directory

First of all, man [*] this kind of directory means. A particularly interesting thing about the Linux help document is that it represents different types and fields (i.e. categories) according to the document. Later, we will say what categories are divided according to. There is something similar: zh_ Cn pl.iso8859-2 these. The document is also divided into language, region and character coding. It can support unified commands, multiple language versions of documents, different regions, and specified character sets. For example: zh_ Tw.big5 means: Chinese_ Taiwan region. Documents encoded using Big5 character set.

Document domain differentiation method (i.e. category)

Let’s look at the following table:

field describe explain
1 User command Can be started by anyone, such as Env, cat, man, touch documents
2 System call or kernel function That is, functions provided by the kernel, such as link, sethostname and MKDIR
3 Library program That is, library functions such as acosh, ASCII, BTREE and locale
4 Equipment related information That is, special files in the / dev directory, such as zero null SDA
5 File format description As described in the format description of / etc / passwd file, it is under this category
6 game Help files for games
7 other Including macro command packages, conventions, etc., such as ARP, boot, regex, UNIX utf8
8 system management It can only be started by root, such as fdisk, fsck, renice, RPM, yum
9 kernel A document used to store kernel routines
n New document May have to move to a more suitable area
o Old document May be retained for a period of time
l Local document Related to this specific system

If the document is of that type, it is placed in manpath / language_ Area. Character set / man [n] directory. There is no regional language, which represents en English documents. Just put it directly under: manpath / man [n]. Basically, most documents are under this.

For example:

There is a command under Linux: passwd modifies the password information, which can be called by each user, so it will be placed under the man1 / directory

However, at the same time, / etc / passwd has a configuration file for saving user account information. Its format and description information documents will be placed in the / man5 directory. In this way, it can be distinguished according to the domain (it will be called this in the future, ha ha). There will be no wrong finding of files with the same name. The types mentioned above: 1, 2, 3, 4, 5, 7 and 8 are often used by us. If I want to know the meaning of / dev / null device, I can find it under the directory: MAN4.

Help file format:

Just now, the directory storage format and the help file have its format. The first is the naming format:

[command name. Domain]: the name is the name of the command, function or file name, followed by a dot, followed by the domain character. For example, if the passwd command describes the document, the file name is: passwd. 1, and the directory is stored as: man1 / passwd. 1. If the corresponding passwd format describes the document, it will be: man5 / passwd. 5. Take the following example:

[[email protected] man5]$ ls p*      
pam.5.gz       pam_env.conf.5.gz  passwd.5.gz  png.5.gz  
pam.conf.5.gz  pam_krb5.5.gz      pbm.5.gz     pnm.5.gz  
pam.d.5.gz     pam_ldap.5.gz      pgm.5.gz     ppm.5.gz  
#/Usr / share / man / man5 all the following files starting with P. from the file, we can know that it corresponds to the format description of those configuration files.
#PAM. D.5.gz is the description of PAM. D directory structure    Pam.5.gz is the description of PAM module structure

From this point of view, the end of. GZ seems to have been compressed through gzip. In order to save document storage space, the built-in documents of Linux system have been compressed. Just for viewing, we need to unzip and view. The content of the document will not change.


Careful friends must see a problem. It shows that in the structure example under the man directory, in addition to man [n] and the language region directory. There is another category of directories: man1, man0p, man1p, man1x. Here is the description:

Plus P: indicates POSIX programmer program description document

Plus X: indicates x Windows desktop program description document

0P: indicates some C header libraries of POSIX programmer, such as TCP. H, ulimit. H and other documentation

Man pages file content format specification

It can quickly and easily query Linux documents, in addition to directory specification and naming specification. There is also a format specification for the content of the document.

A text file, not in word format, is basically ASCII characters. What are the specifications?

A friend might say that yes, it is indeed a text file. Editing a random TXT file can be a Linux document. For example, you write a script: testellow.sh, and then you write a text and save it as a file: man / man1 / testellow. 1. This is a document.

You can find it through the Linux index method. However: it is not a normative document.

Standard format documents are:

Man page content



Name, manual section number and release date of program or command


How to invoke the command, with a complete list of all options and parameters


A brief summary of commands and their usage


The return value of a program or library function, and the environment in which a specific return value is generated


Often used as an alternative to turnvalues


An alphabetical list of options and parameters, if any


List of files used or available by the command


Concise syntax in the language of the program, if any


List of environment variables used or available by the command


List of error messages generated by the command and their solutions


All information that cannot be classified into any other category


List any standards that the procedure follows, such as POSIX or ISO


Cross index and information related to commands


Point out known bugs and error functions, and how to contact the program author to correct them


The name of the author or maintainer of the command, possibly with an e-mail address or URL address

If there are relevant descriptions in the specification documents, the above node types will be included. Let’s give an example:

[[email protected] ~]$ gtbl cat.1  | gtbl | groff -Tascii -man     
CAT(1)                           User Commands                          CAT(1)
       cat - concatenate files and print on the standard output
       cat [OPTION] [FILE]...
       Concatenate FILE(s), or standard input, to standard output.
       cat f - g
       Written by Torbjorn Granlund and Richard M. Stallman.
       Report bugs to <[email protected]>.
       Copyright (C) 2006 Free Software Foundation, Inc.
       The full documentation for cat is maintained as a Texinfo  manual.   If
cat 5.97                          March 2007                            CAT(1)

Here I unzip a cat.1.gz, and then view the document format through the built-in commands, as shown in the figure above. You can see that many commands are used to display a document. We will know the reason in the document query in the next section.

This is mainly about the Linux document structure, including directory, naming, document name, format, etc. These are not mandatory, and the system is not good at forcibly detecting whether your own documents meet the requirements. However, if you have your own documents and want to add them to the system index, do it according to the regulations, so that the future management will not be confused. As the saying goes: no law, no square. That’s the reason. Hehe, what I said today is rather wordy. I don’t know if I have made it clear. This time it’s more theoretical. In the next section, I’ll actually search documents.

Recommended Today

Apache sqoop

Source: dark horse big data 1.png From the standpoint of Apache, data flow can be divided into data import and export: Import: data import. RDBMS—–>Hadoop Export: data export. Hadoop—->RDBMS 1.2 sqoop installation The prerequisite for installing sqoop is that you already have a Java and Hadoop environment. Latest stable version: 1.4.6 Download the sqoop installation […]