Linux shell command Quick get system help (i) [man-pages definition Specification]_linux Shell

Source: Internet
Author: User
Tags documentation posix command access sub domain

As just learning Linux friends, we get a command, do not know how to use, the general will first look at the command default parameter description, and then do not know is through the Man Command Access manual. Still can't find the method, on the Internet search, finally can't go to the big forum post. Because a lot of time to send posts estimated to be more long someone reply. Over time, the enthusiasm for learning Linux has been neglected. In fact, this is the most difficult to learn Linux.

The Linux command help, generally has 2 kinds, the command own code inside has the use help explanation, this is generally very concise, is too long, the program own size as well as the daily maintenance is inconvenient. Another is a CHM format file with Help files, similar to Windows. Below I say these 2 kinds of how to consult.

first, the process of internal 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
# ... Omit
[chengmo@centos5 ~]$ man-h man
, version 1.6d
Usage:man [-ADFHKTWW] [section] [M path] [p Pager] [-s list]
[-M system] [-p string] name ...
#...... Omitted

Here are 2 examples, using the parameters to get commands to use help, which we often use. Said Han off, began to digress ..., hehe

I want to say the command. Common parameter rules, generally if with a parameter is a character, then use: a "-" connection, if the following argument is more than one character is used: "--" connection. is not a "-" can not be followed by more than one character? This is the flexibility of Linux command parsing, and if you use multiple characters with a "-" connection, it splits it into multiple parameters. For example: Ls–al equivalent to Ls–a–l, if you use: Ls–-al then it will take al as a whole parameter.
Also, the General Linux command will use-H, or--help, as a command line to return command-line help information. Especially--help most, some command 2 support. This has become a habit. If you encounter a command that you won't use, try these 2 parameters.

Second, obtain the command external Help file (man-pages)

What is a man page (man-pages)

Under Windows, we often call the Help manual an ebook, a CHM file. The Help manual below Linux is generally called man-pages. They are stored in some Linux folders in a certain way, if you need to check, you can access the Man-pages Manual index, Common: Info,man (this article is mainly about), Xman and so on. Speaking of which, there must be a friend who would say: "Is it convenient to have a CHM under Windows, search, query, and presentation?" In the shell Terminal view, is not a large piece of text, alone boring, dense. Haha, I can say that it is also rich in content, support ordinary text, tables, pictures, and also is the search to locate the need for information super fast. It must be a few times faster than clicking through the mouse in Windows.

So why is it easy to manage and indexed faster? Next, let's take a look at Man-pages's specifications.

Man-pages directory and filename specification definition
Storage directory:

The first is the directory and the storage specification, where Linux documents are often placed in the directory specified by the MANPATH environment variable. Generally in:/usr/share/man this directory inside. The following structure is also defined in this directory:

[chengmo@centos5 man]$ ls bg  el  fr            hu& nbsp;           it. utf-8  man1   man2x  man4   man6   man8   Pl. iso8859-2  ro         sk  zh_cn cs  Fr. iso8859-1  id            ja         man1p  man3   man4x  man6x  man8x  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  Pl     pt_br         ru. utf-8   TR #可以分为 <strong>2 class </strong&gt, one is man[*] directory, one is: EN,ZH_CN,PL. Iso8859-2 classes represent languages already regions, encoded directories

First of all, man[*] This kind of catalogue means meaning. Linux Help documentation, a particularly interesting one is that, according to the document, the different types, the sub domain (that is, the category), we will say that the category according to what points. There is a similar: ZH_CN pl. Iso8859-2 these. The document is also divided into languages. Geography. Character encoding. You can support unified commands, multiple language versions of documents, and geographies can be different, and you can specify character sets. such as: Zh_tw.big5 This means: Chinese _ Taiwan region. Documents encoded using the BIG5 character set.


Document Domain differentiation methods (that is, categories)

Let's look at the following table:

Field Describe Description
1 User command Can be started by anyone, such as Env, CAT, man, touch document
2 system call or Kernel function Functions provided by the kernel, such as link, sethostname, mkdir
3 Library Program That is, library functions such as Acosh, Asctime, Btree, Locale
4 Device-related information A special file in the/dev directory, such as zero null SDA
5 File Format description As described in the/etc/passwd file format description under this category
6 Game Help file for games
7 Other Includes macro command packs, conventions, etc. such as ARP, boot, regex, Unix UTF8
8 System Management Can only be started by root such as Fdisk, fsck, Renice, RPM, yum
9 Kernel A document for storing kernel routines
N New Document May want to move to a more appropriate field
O Old document may be retained for a period of time
L Local document Related to this particular system

If the document belongs to that type, it is placed under the manpath/language _ area. Character Set/man[n] directory. There is no regional language, the Representative is en English document. Directly below: Manpath/man[n], basically most of the documents are underneath this.

Give me a column:

Linux under the command is: passwd Modify the password information, each user can call, so it will be placed under the man1/directory

But at the same time,/ETC/PASSWD has a Save user account information profile, its format and description information document, will be placed in the/man5 directory. So according to the field (hereafter all called this, hehe) distinguish, will not appear the same name file wrong situation. The above mentioned: 1,2,3,4,5,7,8 These types are often used by us. If I want to know the meaning of the/dev/null device, I can get to: Man4 the directory below.

Help file format:

Just said, the directory storage format, the Help file has its format as well. First, the naming format:

[command name. Field]: The name is the name of the command, function, or file name, followed by a point and then the field character. For example: If passwd command documentation, file name is: Passwd.1, plus the directory stored as: Man1/passwd.1, if the corresponding passwd format description document, it will be: Man5/passwd.5. Look at the following example:

[chengmo@centos5 man5]$ ls p* 
pam.5.gz pam_env.conf.5.gz passwd.5.gz png.5.gz pam.conf.5.gz pam_krb 
5.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 faces start with a P file, from which we know that it corresponds to those configuration file format descriptions.
#pam. d.5.gz is PAM.D directory structure Description pam.5.gz is PAM module structure description

From this inside, the. GZ end appears to have been compressed by gzip, and the Linux system has been compressed to save document storage space with documents. Just look at the time we need to unzip and then view. The contents of the document do not change.

A little more verbose:

Careful friend must see a problem, above shows: The man directory under the structure examples inside, in addition to man[n] and language area directory. There is also a category of categories: man1,man0p,man1p,man1x here Description:

Plus p: Indicates POSIX programmer program documentation

Add x: Represents x Windows desktop program documentation

0p: POSIX programmer some C header file libraries, such as: tcp.h,ulimit.h and other documentation

Man-pages File Content Format specification

Can quickly and easily query Linux documents, in addition to directory specifications and naming conventions. There is also a format specification for the contents of the document.

A text file, not in Word format, basic ASCII characters, what are the specifications?

Maybe friends would say, yes, it is a text file, edit a random txt file, you can be a Linux document, such as: You wrote a: testhellow.sh script, and then you write a text save as: Man/man1/testhellow.1 file. This is even a document.

You can find it by using the Linux indexing method. However: it is not a canonical document.

Canonical format documents are:

Book page content

Description

NAME

Name, manual section number and date of release of the program or order

Synopsis

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

descriptl0n

Short summary of commands and their usage

Return VALUES

A program or library function returns a value, and an environment that produces a specific return value

EXIT STATUS

Often used as a substitute for the costume Turnvalus

OPTIONS

Alphabetical List of options and parameters, if any

FILES

A list of documents used or used by the command

USAGE

Concise syntax for the language of the program, if any

Enviroment

List of environment variables used or used by the command

Diagnostics

List of error messages generated by commands and their solutions

NOTES

cannot be subsumed under any other category of information

Conforming to

List any difficulties that the program follows, such as POSIX or ISO

ALSO

Cross-indexing and information related to commands

BUGS

Point out known bugs and bug features, and how to contact the author of the program to fix them

AUTHOR

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

The documentation for the specification, if any, will contain the above node types. We illustrate the following:

[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. Omit ....   examples        cat f-g omitted ...     AUTHOR    
    written by Torbjorn Granlund and Richard M. Stallman.   REPORTING BUGS         report bugs to <bug-coreutils@gnu.org>.
  COPYRIGHT        copyright (C) 2006 Free Software Foundation, Inc., omitted .... ALSO        the Full documentation to cat is maintained as a texinfo  manual.    If omitted ....   Cat 5.97                           March 2007                              CAT (1)

Here I unzipped a cat.1.gz and then use the command to view the document format as shown above, you see a lot of commands, display a document, in the next section of the document query we will know why.

This is mainly about the Linux document structure, including directories, naming, already document names, formats, and so on. These are not mandatory and the system is hard to force to detect if your own documents are satisfied. However, if you have a document you want to add to the system index, follow the rules to do, will let management more than chaos. As the saying goes: Irregular radius. This is the reason. Oh, today said more long-winded, do not know whether to say clearly, this time to say the comparative theory, the next section of the actual retrieval of the document aspects.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.