查看內部命令和外部命令幫助 一、內部命令 可以用type來判斷該命令是內部命令還是外部命令,type後加要查看的命令. 示例寫法:type enable 有的命令既有內部命令也有外部命令但是系統會優先使用 ...
查看內部命令和外部命令幫助
一、內部命令
可以用type來判斷該命令是內部命令還是外部命令,type後加要查看的命令.
示例寫法:type enable
[10:52:18 root@centos ~]#type enable
enable is a shell builtin
有的命令既有內部命令也有外部命令但是系統會優先使用內部命令。
例如:type echo ,查看到的是內部命令,但是加上 -a系統會顯示出他的外部命令路徑。
[11:32:59 root@centos ~]#type echo
echo is a shell builtin
[11:33:18 root@centos ~]#type -a echo
echo is a shell builtin
echo is /usr/bin/echo
用help查看全部內部命令的簡單說明
[09:47:49 root@centos ~]#help
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
job_spec [&] history [-c] [-d offset] [n] or history>
(( expression )) if COMMANDS; then COMMANDS; [ elif COMM>
. filename [arguments] jobs [-lnprs] [jobspec ...] or jobs -x >
: kill [-s sigspec | -n signum | -sigspec>
[ arg... ] let arg [arg ...]
[[ expression ]] local [option] name[=value] ...
alias [-p] [name[=value] ... ] logout [n]
bg [job_spec ...] mapfile [-n count] [-O origin] [-s coun>
bind [-lpvsPVS] [-m keymap] [-f filename> popd [-n] [+N | -N]
break [n] printf [-v var] format [arguments]
builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir]
caller [expr] pwd [-LP]
case WORD in [PATTERN [| PATTERN]...) CO> read [-ers] [-a array] [-d delim] [-i t>
cd [-L|[-P [-e]]] [dir] readarray [-n count] [-O origin] [-s co>
command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] or r>
compgen [-abcdefgjksuv] [-o option] [-A> return [n]
complete [-abcdefgjksuv] [-pr] [-DE] [-o> select NAME [in WORDS ... ;] do COMMAND>
compopt [-o|+o option] [-DE] [name ...] set [-abefhkmnptuvxBCHP] [-o option-nam>
continue [n] shift [n]
coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...]
declare [-aAfFgilrtux] [-p] [name[=value> source filename [arguments]
dirs [-clpv] [+N] [-N] suspend [-f]
disown [-h] [-ar] [jobspec ...] test [expr]
echo [-neE] [arg ...] time [-p] pipeline
enable [-a] [-dnps] [-f filename] [name > times
eval [arg ...] trap [-lp] [[arg] signal_spec ...]
exec [-cl] [-a name] [command [arguments> true
exit [n] type [-afptP] name [name ...]
export [-fn] [name[=value] ...] or expor> typeset [-aAfFgilrtux] [-p] name[=value>
false ulimit [-SHacdefilmnpqrstuvx] [limit]
fc [-e ename] [-lnr] [first] [last] or f> umask [-p] [-S] [mode]
fg [job_spec] unalias [-a] name [name ...]
for NAME [in WORDS ... ] ; do COMMANDS; > unset [-f] [-v] [name ...]
for (( exp1; exp2; exp3 )); do COMMANDS;> until COMMANDS; do COMMANDS; done
function name { COMMANDS ; } or name () > variables - Names and meanings of some >
getopts optstring name [arg] wait [id]
hash [-lr] [-p pathname] [-dt] [name ...> while COMMANDS; do COMMANDS; done
help [-dms] [pattern ...] { COMMANDS ; }
查看某一個內部命令詳細說明:
示例寫法:help enable
help後面加上要查看的命令。
[10:45:50 root@centos ~]#help enable
enable: enable [-a] [-dnps] [-f filename] [name ...]
Enable and disable shell builtins.
Enables and disables builtin shell commands. Disabling allows you to
execute a disk command which has the same name as a shell builtin
without using a full pathname.
Options:
-a print a list of builtins showing whether or not each is enabled
-n disable each NAME or display a list of disabled builtins
-p print the list of builtins in a reusable format
-s print only the names of Posix `special' builtins
Options controlling dynamic loading:
-f Load builtin NAME from shared object FILENAME
-d Remove a builtin loaded with -f
Without options, each NAME is enabled.
To use the `test' found in $PATH instead of the shell builtin
version, type `enable -n test'.
Exit Status:
Returns success unless NAME is not a shell builtin or an error occurs.
echo用法及原理
echo可以將你輸入的內容進行顯示,可以加參數,顯示參數標準輸出顯示。並且自動換新行。
-n: 加上-n就是不換行
-e:啟用反斜杠轉義解釋 示例:echo -e '\a' 警報聲 '\a' 加引號。
用法示例:sleep 10;echo -e '\a' 休眠10秒,結束後警報聲提醒
-E:禁用反斜杠轉義解釋
範例:echo的help使用方法
echo內部命令幫助查看:
示例寫法:help echo
[11:33:21 root@centos ~]#help echo
echo: echo [-neE] [arg ...]
Write arguments to the standard output.
Display the ARGs on the standard output followed by a newline.
Options:
-n do not append a newline
-e enable interpretation of the following backslash escapes
-E explicitly suppress interpretation of backslash escapes
`echo' interprets the following backslash-escaped characters:
\a alert (bell) 警報聲提醒
\b backspace
\c suppress further output 壓縮之後的輸出 壓縮掉echo的換行
\e escape character
\f form feed
\n new line 換新行 本身echo就帶有換行,再加\n表示換兩行。
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\0nnn the character whose ASCII code is NNN (octal). NNN can be
0 to 3 octal digits
\xHH the eight-bit character whose value is HH (hexadecimal). HH
can be one or two hex digits
Exit Status:
Returns success unless a write error occurs.
二、外部命令
帶有路徑的都是外部命令。
示例:passwd --help
[13:55:39 root@centos ~]#type passwd
passwd is hashed (/usr/bin/passwd)
[13:01:45 root@centos ~]#passwd --help
Usage: passwd [OPTION...] <accountName>
-k, --keep-tokens keep non-expired authentication tokens
-d, --delete delete the password for the named account (root only)
-l, --lock lock the password for the named account (root only)
-u, --unlock unlock the password for the named account (root only)
-e, --expire expire the password for the named account (root only)
-f, --force force operation
-x, --maximum=DAYS maximum password lifetime (root only)
-n, --minimum=DAYS minimum password lifetime (root only)
-w, --warning=DAYS number of days warning users receives before password
expiration (root only)
-i, --inactive=DAYS number of days after password expiration when an account
becomes disabled (root only)
-S, --status report password status on the named account (root only)
--stdin read new tokens from stdin (root only)
Help options:
-?, --help Show this help message
--usage Display brief usage message
echo外部命令查看幫助:
示例寫法:/bin/echo --help
[12:25:14 root@centos ~]#/bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
or: /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
--help display this help and exit
--version output version information and exit
If -e is in effect, the following sequences are recognized:
\\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\0NNN byte with octal value NNN (1 to 3 digits)
\xHH byte with hexadecimal value HH (1 to 2 digits)
NOTE: your shell may have its own version of echo, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'echo invocation'
(echo以上的寫法查看到的幫助用法是相同的,但是幫助內容不一樣,僅供參考。)