Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get system help quickly with linux shell command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to get system help quickly with linux shell commands". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Help information inside the program

For example:

[chengmo@centos5] $cat-- helpUsage: cat [OPTION] [FILE]... Concatenate FILE (s), or standard input, to standard output. -A,-show-all equivalent to-vET#. Omit [chengmo@centos5] $man-hman, version 1.6d usage: man [- adfhktwW] [section] [- M path] [- P pager] [- S list] [- m system] [- p string] name. Omit

The above are two examples of getting command help through parameters, which we often use. Say something beside the point and start to digress. Oh, ha ha.

I would like to talk about the common parameter rules of the command, generally if the parameter is a character, then use: a "-" connection, if the subsequent parameter is multiple characters, use: "-" connection. Is it possible that multiple characters cannot be followed by a "-"? This is the flexibility of linux command parsing. If you concatenate multiple characters with a "-", 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.

Also point out that most linux commands use-h or-- help as the return command line help information. In particular-- 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 two parameters.

Second, get the command external help file (man-pages)

What is a man page (man-pages)

Under windows, we often call help manuals e-books, which are chm files. The help manual under linux is generally called man-pages. They are stored in some linux folders according to a certain rule, and if you need to consult them, you can consult them through the man-pages manual index command, commonly seen as: info,man (the main topic of this article), xman and so on. At this point, there must be friends who will say: is it convenient to search, query, and express the chm under windows? Check in the shell terminal, is not a large piece of text, alone boring, dense. Haha, what I can say is that its content is still very rich, supporting ordinary text, tables, pictures, and search to locate the need for information very fast. 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 the storage specification. Linux documents are often placed in the directory specified by the MANPATH environment variable. It's usually in the directory: / usr/share/man. The following structure of this directory is also defined:

[chengmo@centos5 man] $lsbg el fr hu it.UTF-8 man1 man2x man4 man6 man8 manl pl.ISO8859-2 ro sk zh_CNcs en fr.ISO8859-1 id ja man1p man3 man4x man6x man8x mann pl.UTF-8 ru sl zh_TWda es fr.UTF-8 it ko man1x man3p man5 man7 man9 nl pt Ru.KOI8-R svde fi hr it.ISO8859-1 man0p man2 man3x man5x man7x man9x pl pt_BR ru.UTF-8 tr# can be divided into two categories One is the man [*] directory, and the other is: en,zh_CN,pl.ISO8859-2 represents the language region, coding directory

First of all, a catalog like man [*] means something. What is particularly interesting about the linux help documentation is that it is classified into different types (that is, by category) according to the document, and we will talk about how this category is divided in a moment. There is something similar: zh_CN pl.ISO8859-2. The document is also divided into languages. Region. Character encoding. Can support unified commands, multiple language versions of documents, and the region can be different, but also can specify the character set. For example, the meaning of zh_TW.big5 is: Chinese _ Taiwan. Documents that are encoded using the big5 character set.

Document domain differentiation method (that is, category)

Let's take a look at the following table:

Domain description description 1 user commands can be initiated by anyone Such as env, cat, man, touch documentation 2 system calls or kernel functions such as link, sethostname, mkdir3 library programs, that is, library functions such as acosh, asctime, btree, locale4, special files in the / dev directory such as zero null sda5 file format description such as / etc/passwd file format description under this category 6 games help files 7 other including macro command packages, conventions, etc., such as arp, boot, regex, Unix utf88 system management can only be started by root, such as fdisk, fsck, renice, rpm, yum9 kernels to store kernel routines n new documents may be moved to a more suitable area o old documents may retain l local documents related to this particular system for a period of time

If the document is of that type, it is placed in the MANPATH/ language _ area. Under the character set / man [n] directory. There is no regional language, the representative is en English document. Just put it directly under: MANPATH/ man [n], basically most of the documents are under this.

Let me give you a list:

There is a command under linux: passwd can change password information, which can be called by every user, so it will be placed under the man1/ directory.

But at the same time, / etc/passwd has a profile for saving user account information, and its format and description documents will be placed in the / man5 directory. In this way, according to the domain (later called this, hehe), there will be no mistakes in finding files with the same name. 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 / dev/null device, I can look under the directory: man4.

Help file format:

As I just said, the directory storage format, help files also have its format. The first is the naming format:

[command name. Domain]: a name is the name of a command, function, or file name, followed by a dot, followed by a domain character. For example: if the passwd command description document, the file name is: passwd.1, plus the directory is stored as: man1/passwd.1, if the corresponding passwd format description document, it will be: man5/passwd.5. Take a 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_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 files that begin with p We know from the file that it corresponds to those configuration file format descriptions. # pam.d.5.gz is the pam.d directory structure description pam.5.gz is the pam module structure description

From this point of view, the .gz ending seems to have been compressed through gzip, and the linux system has compressed its own documents in order to save storage space. Just when we look at it, we need to extract it and check it. The content of the document does not change.

Let's talk about it again:

Careful friends must see a problem, the above shows: man directory under the structure example, in addition to man [n] and language region directory. There is another category of catalogs: man1,man0p,man1p,man1x, which is explained here:

Plus p: indicates the POSIX Programmer program description document

Add x: indicates x windows desktop program description document

0p: indicates the header file library of some c of POSIX Programmer, such as tcp.h,ulimit.h, etc.

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 content of the document.

A text file, not in word format, is basically ascii characters, what other specifications?

Friends may say, yes, it is indeed a text file, edit a random txt file, it can be a linux document, such as: you write a: testhellow.sh script, and then you write a text saved as: man/man1/testhellow.1 file. This is a document.

You can find it through the linux index method. However: it is not a canonical document.

The standard format documents are:

Man Page content

Description

NAME

The name, manual section number and release date of the program or command

SYNOPSIS

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

DESCRIPTl0N

A brief summary of commands and their usage

RETURN VALUES

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

EXIT STATUS

It is often used to replace TURNVALUS.

OPTIONS

An alphabetical list of options and parameters, if any

FILES

List of files that can or can be used by the command

USAGE

Concise syntax described in the language of the program, if any

ENVIROMENT

List of environment variables that can or can be used by the command

DIAGNOSTICS

A list of error messages generated by commands and their solutions

NOTES

All the information that cannot be grouped under any other category

CONFORMING TO

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

SEE ALSO

Cross-indexing and information related to commands

BUGS

Point out known bug 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, possibly with an e-mail address or URL address

Canonical documentation, if there is a description, will include the above node types. Let us 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. Omit. EXAMPLES cat f-g is omitted. AUTHOR Written by Torbjorn Granlund and Richard M. Stallman. REPORTING BUGS Report bugs to. COPYRIGHT Copyright (C) 2006 Free Software Foundation, Inc. Omit. SEE ALSO The full documentation for cat is maintained as a Texinfo manual. If omitted. Cat 5.97 March 2007 CAT (1) "how to get system help quickly with linux shell commands" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report