As friends who have just learned Linux, we got a command and don’t know how to use it. We usually look at the command default parameter description first, and then we don’t know what to do. We just use the man command to check the manual. Still couldn't find a way, so I searched online, and in the end I didn't work, I would post on the big forum. Because it is often time to post a post, someone will reply. Over time, my enthusiasm for learning Linux was neglected. In fact, this is also the biggest difficulty in learning Linux.
There are generally two types of linux command help. The command itself contains instructions for using help. This is generally very simple and too long, and the size of the program itself and daily maintenance are inconvenient. Another type is a chm format file with help files, similar to Windows. Let me tell you how to check these two types.
1. Program inherent help information
For example:
[chengmo@centos5 ~]$ cat --help Usage: cat [OPTION] [FILE]... Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to -vET #...Omitted [chengmo@centos5 ~]$ man -h man, version 1.6d usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list] [-m system] [-p string] name ... #......Omitted
The above are 2 examples, and we use commands through parameters, which we often use. Say something off topic and start off topic..., haha
I want to talk about the common parameter rules of commands. Generally, if the parameter with a character is one, then use: one "-" to connect. If the following parameter is multiple characters, use: "-" to connect. Is it a "-" Can't be followed by multiple characters? This is the flexibility of parsing linux commands. If you connect multiple characters with one "-" it will split it into multiple parameters. For example: ls –al is equivalent to ls –a –l . If you use: ls –-al then it will take al as the overall parameter.
I would like to say that generally, linux commands will use -h, or --help as the return command line help information. Especially -- help is the most, and some commands support both. This has become a habit. If you encounter commands that you don’t know how to use, you might as well try these 2 parameters.
2. Obtain external help files for commands (man-pages)
What is a man page (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 check it, you can check it through the man-pages manual index command. Common ones include: info, man (the main topic of this article), xman, etc. Speaking of this, some friends will definitely say: Is it convenient to have chm below Windows? What is the search, query, and expression form? Checking on the shell terminal, is it all a large number of texts, boring and dense. Haha, what I can say is that its content is rich and supports ordinary text, tables, pictures, and search and positioning information that requires super fast. It must be several times faster than clicking through the mouse in Windows.
So why is it easy to manage and index faster? Next, let's take a look at the specifications of man-pages.
man-pages directory and file name specification definition
Storage directory:
First of all, the directory and storage specifications. Linux documents are often placed in the directory specified by the MANPATH environment variable. Generally in: /usr/share/man directory. The following structure of this directory is also defined:
[chengmo@centos5 man]$ ls bg el fr hu -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 -8 ru sl zh_TW da es -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 -8 tr #Can be divided into<strong>2kind</strong>,一kind是man[*]Table of contents,一kind是:en,zh_CN,pl.ISO8859-2kind代表语言已经地区,编码Table of contents
Let me talk first, a directory like man[*] means meaning. A special and interesting thing about Linux help documents is that they represent different types and fields (that is, categories). After that, we will talk about what classification is divided into this category. There are also similar ones: zh_CN pl.ISO8859-2. Documents are also divided into language, region, and character encoding. It can support unified commands, multiple language versions of documents, and the regions can be different, and character sets can also be specified. For example: zh_TW.big5 means: Chinese_*. Documents encoded using big5 character set.
How to distinguish between document fields (that is, category)
Let's look at the following table:
field | describe | illustrate |
1 | User Commands | Can be started by anyone, such as env, cat, man, touch documents |
2 | System calls or kernel functions | That is, functions provided by the kernel such as link, sethostname, mkdir |
3 | Library Programs | That is, library functions such as acosh, asctime, btree, locale |
4 | Information related to the device | That is, special files in /dev directory such as zero null sda |
5 | File format description | For example, the /etc/passwd file format description is described under this category |
6 | game | Game help files |
7 | other | Including macro command packages, conventions, etc., such as arp, boot, regex, unix utf8 |
8 | System Management | Only start by root, such as fdisk, fsck, renice, rpm, yum |
9 | Kernel | Documents used to store kernel routines |
n | New Documents | It may be moving to a more suitable area |
o | Old documents | May be retained for a period of time |
l | Local Documentation | Related to this specific system |
If the document belongs to that type, it is placed under the MANPATH/Language.character set/man[n] directory. There is no regional language, it means en English documents. Just put it directly below: MANPATH/man[n], basically most of the documents are below this.
Let me give you a list:
There is a command under linux: passwd to modify password information, which can be called by each user, so it will be placed under man1/ directory
But at the same time, /etc/passwd has a configuration file to save user account information. Its format and description information document will be placed in the /man5 directory. In this way, differentiate according to the domain (this will be called this in the future, haha), and there will be no errors in finding files of the same name. The above mentioned: 1, 2, 3, 4, 5, 7, 8 are the types we often use. If I want to know the meaning of the /dev/null device, I can search in the directory:man4.
Help file format:
As I said just now, the directory storage format and the help file also have its format. First is the naming format:
[Command Name.Domain]: The name is the name of a command, function or file name, followed by a dot and then the domain character. For example: if the passwd command describes the document, the file name is: passwd.1, plus the directory is stored as: man1/passwd.1, if the passwd format description document is corresponding to the passwd format, it will be: man5/passwd.5. Take a look at the following example:
[chengmo@centos5 man5]$ ls p* pam. pam_env.conf. passwd. png. . pam_krb5. pbm. pnm. . pam_ldap. pgm. ppm. #/usr/share/man/man5 All the files below start with p, from the file we know that they correspond to the configuration file format description.#.It's the directory structure description pam.yespamModule structure description
From this point of view, the ending of .gz seems to be compressed through gzip. In order to save document storage space, the Linux system has all the files in it are compressed. Just when viewing, we need to unzip and then view. The content of the document will not change.
Let's talk about it again:
Careful friends must see a problem. The above shows: In the structure example below the man directory, in addition to the man[n] and the language region directory. There is another category of directories: man1,man0p,man1p,man1x. Here is the explanation:
Add p: indicates the POSIX Programmer program description document
Add x: means x windows desktop program description document
0p: indicates that some C header file libraries of POSIX Programmer, such as:, etc.
man-pages file content format specification
It can quickly and conveniently query Linux documents, in addition to directory specifications and naming specifications. There is also a format specification for the content of the document.
A text file does not use word format, it is basically all ascii characters. What are the specifications?
Maybe a friend would say this, yes, it is indeed a text file. Editing a random txt file can be a linux document, such as: you wrote a script, and then you wrote a text saved as: man/man1/testhellow.1 file. This is a document.
You can find it through the linux index method. But: it is not a canonical document.
The specification format document is:
Man page content |
describe |
NAME |
The name of the program or command, manual section number and release date |
SYNOPSIS |
How to call a command, complete list of all options and parameters |
DESCRIPTl0N |
A brief summary of commands and their usage |
RETURN VALUES |
Program or library function returns values, and environments that produce specific return values |
EXIT STATUS |
Often used to replace TURNVALUS |
OPTIONS |
Alphabetical list of options and parameters, if any |
FILES |
List of files that can be used by the command or can be used |
USAGE |
Concise syntax for the language of the program, if any |
ENVIROMENT |
List of environment variables used by commands or can be used |
DIAGNOSTICS |
List of error messages generated by commands and solutions |
NOTES |
All information that cannot be classified under any other category |
CONFORMING TO |
List any difficulties that the program follows, such as PoSIX or ISO |
SEE ALSO |
Cross-index and information related to commands |
BUGS |
Point out your known bugs and error functions, and how to contact the author of the program to correct them |
AUTHOR |
The name of the author or maintainer of the command, which may have an email or URL address |
Specification documents, if there are relevant descriptions, will contain the above node types. Let’s give an example:
[chengmo@centos5 ~]$ gtbl cat.1 | gtbl | groff -Tascii -man CAT(1) User Commands CAT(1) NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION] [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. Omitted.... EXAMPLES cat f - g Omitted.... AUTHOR Written by Torbjorn Granlund and Richard M. Stallman. REPORTING BUGS Report bugs to <bug-coreutils@>. COPYRIGHT Copyright (C) 2006 Free Software Foundation, Inc. Omitted.... SEE ALSO The full documentation for cat is maintained as a Texinfo manual. If Omitted.... cat 5.97 March 2007 CAT(1)
Here I unzip a cat. Then I check the document format through the built-in commands as shown in the figure above. You see that many commands are used to display a document. We will know the reason in the next section of the document query.
What we mainly talk about here is the linux document structure, including directories, naming, existing document names, formats, etc. These are not mandatory, and the system is not able to force the detection of whether your own documents are satisfied. However, if you have your own documents that want to be included in the system index and do it according to the regulations, it will make the future management more confusing. As the saying goes: No rules can lead to squares and circles. This is the reason. Haha, what I said today is quite long-lasting, I don’t know if I have made it clear. This time I said it is more theoretical, and I will actually search for documents in the next section.