Basic CentOS help documentation-common commands

Source: Internet
Author: User
Tags builtin
For more information about linux basic help documentation, see-2014.2.11 --- the first man in common commands: whatis1, man manual search format-input? Key, forward search, such? -H: Searches for rows containing "-h", such as/-k, the "-k" rows will be searched backward, and the corresponding matching items of the previous one will be viewed by N or n (next. 2,

View basic linux help documentation-2014.2.11

--- Common commands

First man: Related Command whatis

1, Man manual search format

-Input? Key, forward search, such? -H: Searches for rows containing "-h ".

-Enter the/key and search backward, for example,/-k. The "-k" row is searched backward.

Check the previous matching item by N or n (next.

2Location where man manual is stored

You can use the manpath command to view the manpage location.

3, Man manual page entry

1 User Command 2 System 3 Library 4 device 5 file system

6 Games 7 Miscellaneous 8 system commands 9 kernel commands

Generally used:, 8

4Generally, when you use man to view the help document of a command, you can use whatis to view the entry of this command in the man help document. a command may have multiple man manual page entries (note: when using whatis, if the linux computer is started for 70 minutes, you can use it on your own. if The linux computer is just started, run the makewhatis command to compile it, otherwise, you cannot use the whatis command)

[Root @ localhost ~] # Whatis rm

Rm (1 p)-remove directory entries

Rm (1)-remove files or directories

[Root @ localhost ~] # Whatis passwd

Passwd (1)-update user's authentication tokens

Passwd (5)-password file

Passwd (rpm)-The passwd utility for setting/changing passwords using PAM

Passwd [sslpasswd] (1ssl)-compute password hashes

When you use man to query rm or passwd commands, you can enter:

Man 5 passwd // query the help document of passwd for the file system at the entry

Man 1 passwd // query the help document of passwd for user commands at the entry

Man 1/1 p rm






Second: help: related command type, which

1First, explain the internal commands and external commands.

In short, commands with storage locations in linux are external commands;

An internal command is stored in a linux shell.

2, The help document of external commands uses the help format: Command -- help

Example: passwd -- help

The help document of internal commands uses the help format: help-command

For example, help cd

3, Type to determine whether it is an internal command or an internal command

For example:

[Root @ localhost ~] # Type help // view the internal and external types of the help command

Help is a shell builtin // you can see that help is an internal command

[Root @ localhost ~] # Type passwd // check whether the passwd command exists in linux

Passwd is/usr/bin/passwd // you can see the storage location of passwd.

[Root @ localhost ~] # Type cd

Cd is a shell builtin

Passwd is an external command, and cd is an internal command.

4. use the which command to find executable files (external commands and scripts)

-The which command is too long to explain, so it is a different solution.

4-1The scope of which can be searched is determined by the environment variable PATH. Generally, the administrator and common user's PATH variables are different, you can log on to the root user and normal user test and run echo $ PATH to view the logs.

[Root @ localhost ~] # Su-root

[Root @ localhost ~] # Su-test // switch to the test user

[Test @ localhost ~] $ Echo $ PATH // view the environment variables of the test user

/Usr/kerberos/bin:/usr/local/bin:/usr/bin:/home/test/bin

[Test @ localhost ~] $ Exit

Logout

[Root @ localhost ~] # Echo $ PATH // view the root user's environment variables

/Usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/root/bin

[Root @ localhost ~] #

4-2, Use which to view the execution program location of mkdir and cp commands:

[Root @ localhost ~] # Where the which mkdir // mkdir command is stored

/Bin/mkdir

[Root @ localhost ~] # Which cp // where the cp command is stored

Alias cp = 'CP-I'

/Bin/cp

[Root @ localhost ~] #

From the above results, we can see that the which output includes The Command alias. This is because Linux sets the which alias to add an alias for search for convenience.

4-3To view the result of the which cp command.

[Root @ localhost ~] # Alias which // view the alias of which is actually equivalent to the following green command combination

Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'

[Root @ localhost ~] #/Usr/bin/which mkdir // only search for the first target

/Bin/mkdir

[Root @ localhost ~] #/Usr/bin/which cp

/Bin/cp

[Root @ localhost ~] #

4-4, Which parameter-

When the PATH of the which query is $ PATH, it is directly displayed after the directory where the First Command is located. if this command exists in the following directory, it will not be displayed, therefore, you must use the-a parameter.

[Root @ localhost ~] # Which-a mkdir // find all targets

/Bin/mkdir

/Usr/bin/mkdir

4-5Because internal commands are built in the/bin/bash interpreter and there is no independent executable file, you cannot find them by using which. For example, if you use which to find internal commands such as cd and help, the system will prompt that the result cannot be found.

[Root @ localhost ~] # Which cd // view the location of the internal command cd

/Usr/bin/which: no cd in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin: /sbin:/bin:/usr/sbin:/usr/bin:/root/bin) // you can see that it does not exist.

[Root @ localhost ~] # Which help

/Usr/bin/which: no help in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin: /sbin:/bin:/usr/sbin:/usr/bin:/root/bin)


[Root @ localhost ~] #



Note: Generally, use the help command to view internal commands !!!



This is the most basic linux help command. although it is simple, its usage is often mixed. Originally, the which command was intended to get the whereis, which, whatis, and locate commands, I am afraid to confuse myself. whatis and which are here now!

 

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.