1.HELP displays a list of all built-in commands, or the use of a built-in command
#help//View all built-in commands
#help built-in commands//view built-in command usage
#help-S built-in command//display the syntax format of the built-in commands, very useful Oh!
[[email protected] var]# help-s CD
CD:CD [-l|-p] [dir]
2.echo is used to display a line of text and is automatically wrapped by default
[Email protected] ~]# echo www
Www
-E lets special characters in a string work. For example:
[[Email protected] ~] #echo-E "I am the King\nof the world."
The results of the implementation are as follows:
I am the King
of the world.
where \ n is translated into a newline character.
3.printf Display parameter contents according to format
Suppose the variable str= "Hello World"
[[Email protected] ~] #printf "%s\n" "$str"
Hello World
#显示变量str的内容, and \ n has a line-wrapping effect.
[[Email protected] ~] #printf "%c\n" "$str"
H
#显示变量值的第一个字符
[[Email protected] ~] #printf "%s total%d characters \ n" "$str" 11
Hello World A total of 11 characters
#显示str = "Hello World" has a total of 11 characters.
[[Email protected] ~] #printf "%9s\n" hello!
___hello!
#显示9个字符长度的字符串 (right-aligned), the part with less than 9 characters is padded with whitespace, and the results show "___hello!" (3 characters left) [[Email protected] ~] #printf "%-9s\n" hello!
#显示9个字符长度的字符串 (left-aligned), a portion of less than 9 characters is padded with whitespace, resulting in "hello!___"
[[Email protected] ~] #printf "%5.8f\n" 300
300.00000000
The #在上述的字符串中, 5.8 of 5, indicates a total of 5 digits with a decimal point, and 5.8 in 8 means that the number of small digits occupies one bit.
[[Email protected] ~] #printf "%q\n" "$str"
"Hello\world"
#这里的%q parameter is to escape special characters
[[Email protected] ~] #printf-v myvar "%q" "ABC 123 XYZ"
#这里的-V is said: Do not display to the standard output, and the value of the content you want to display to the variable myvar.
#myvar变量为 "ABC\123\XYZ"
[[Email protected] ~] #printf "%b" "abc\n123\nxyz\n"
#%b is to say that the special character escape takes effect, which means that n in the string will have a newline effect.
#结果如下: ABC
123
Xyz
[[Email protected] ~] #printf "%s\n" "Abcdefghijk" |tr A-Z
#把字符串显示出来, pass the pipe to TR and turn the uppercase letter into lowercase.
#结果: Show Abcdefghijk
4.CD Changing directory Location
[Email protected] ~]cd
#执行后回到家目录, equivalent to CD ~
[Email protected] ~]CD-
[Email protected] ~]# Cd/var/log
[Email protected] log]# CD-
/root
[Email protected] ~]#
#回到先前的目录
[Email protected] ~]CD.
#回到上一层目录
5.PWD displays the current working directory
[Email protected] ~]pwd
/root
#显示当前工作路径
6.:(colon) do nothing, return the true value (that is, return 0)
[[Email protected] ~]: >AA
You can create an empty file with a name of AA
7.. (Half-width period) Execute Shell program in the current shell environment
[[Email protected] ~]. aa.sh
Note: You must add at least one space prompt to the shell program.
The same function as the source command
8.source executing shell programs in the current shell environment
[Email protected] ~]source aa.sh
9.alias display, set program alias
[Email protected] ~]alias
#执行后, displays all currently set program names.
[Email protected] ~]alias help1= ' help-s test '
#alias New alias = "Combined Program"
[Email protected] ~]alias CP=CP
#取消程序别名, CP is also the original CP command (default is Cp-i).
10.unalias
[email protected] ~]unalias CP
#表示把cp的别名设定取消
11.exit leave bash shell or end script program
Leave the shell and return the value 1
12.logout Logout Login Shell
In the case where no strings are entered on the command line, pressing the [CTRL D] key combination is equivalent to the logout instruction and can be logged off.
13.umask Display or set permissions mask for new files and directories
[Email protected] ~]umask
#执行后, displays the current umask mask
[[email protected] ~]umask-s 0024
#执行后, set the umask mask to 0024
14.history shows shell commands that have been executed in the past
[[Email Protected]~]histroy
#执行结果, displays commands that have been executed by a Linux host
Histroy variables:
Histfile View history file name and storage path
[Email Protected]~]echo $HISTFILE
/root/.bash_history
Histfilesize viewing the number of files stored
[Email Protected]~]echo $HISTFILESIZE
1000
Histsize the number of history commands saved under the current shell
[Email Protected]~]echo $HISTSIZE
1000
15.FC lists the most recently executed commands after logging in to the host
-
[[email protected]~]fc-l
-
Span style= "FONT-SIZE:16PX;" > #显示登录后最近执行过的命令
-
[[email protected]~]fc-ln
-
#不显示命令的编号
-
[[ EMAIL PROTECTED]~]FC-L ll CP
-
#显示ll和cp两条命令之间的历史命令
-
-
-
[[email protected ]~]FC-LR
-
show commands in large to small numbers
16.type determine how bash interprets an instruction (this command is the type of command you see)
-
FG is a shell builtin //FG is a shell's built-in name in a
-
[[email protected] ~]# type if
-
if is a shell keyword //if a reserved field for the shell
-
[[email protected] ~]# type CP
-
CP is aliased to ' cp-i '  //CP ' cp-i ' program alias
-
[[email protected] ~]# type tr
-
tr is/usr/bin/tr //tr is a standalone execution program with the program path/usr/bin /tr
17.set sets the properties of the bash shell and, without any options and arguments, displays the contents of all shell variables and functions.
[[Email Protected]~]set
#查看当前shell环境变量和函数
[[Email Protected]~]set-o|grep on
[Email protected] ~]# Set-o|grep on
Braceexpand on
Emacs on
Hashall on
Histexpand on
History on
Interactive-comments on
Monitor on
Onecmd off
#查看目前shell所有的属性的开关状态
#开始一个bash the properties of the shell:
[[Email protected]~]set-o emacs (attribute name)]
#关闭一个bash the properties of the shell:
[[Email Protected]~]set +o emacs (attribute name)
#保护已存在的文件, avoid overwriting the contents of the file when turning the output.
[[Email Protected]~]set-o noclobber
[Email protected] ~]# echo > Aaa.txt
-bash:aaa.txt:cannot Overwrite existing file
[[Email Protected]~]set-v
#这个选项会使bash执行Script时, each process code that it reads into is displayed and is usually used for program troubleshooting.
18.shopt set the behavior mode of the bash shell (similar to the SET command)
[[Email protected]~]shopt
#显示目前各选项的开关状态, the same effect as shopt-p execution
[[Email Protected]~]shopt-s
#启用选项
[[Email Protected]~]shopt-u
#关闭选项
[[Email Protected]~]shopt-o
#使用和set-o same option to set
[[Email Protected]~]shopt-q
#不显示开关状态, the callback status option is on or off, 0 table enabled, 1 table off
.!! Represents the execution of the previous command
> redirect, enter a value into the file
>> Follow-up redirect, you can continue to append file content in the file
< reverse redirect, throw a command to the file
23.last commands can see which 650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/ U261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/>ip logged into the Linux system
Common commands under the shell