1. Command history:
Environment variables:
Histfile: Number of records in the command history
Histsize:~/.bash.history
Histfilesize: The number of history records in a command history file
History: Default display of 10 records
History-n: Show post n history
history-d N: Delete nth history
History-c: Delete all history
History-a: Manually append the history command in the current session buffer to the history file
! N: Execute nth command repeatedly
!! : Executes the previous command repeatedly
! Add the first few letters of the command: Repeat the last command that starts with these letters
Control how the Command history is recorded:
Environment variable: Histcontrol:
Ignoredups: Ignore consecutive repeated commands
Ignorespace: Ignore commands that begin with a space
Ignoreboth:ignoredups,ignorespace
[[email protected] ~]# history //View command history, display 10 history by default 28 history 29 ls 30 history | more 31 history 32 history | more 33 ls 34 cd 35 ls 36 cd /.bash.hisory 37 history[[email protected] ~]# history 5 //See the last 5 commands history 34 cd 35 ls 36 cd /.bash.hisory 37 history 38 history 5[[email protected] ~]# history -d 36 // Delete 36th command History,[[email protected] ~]# history 5 //See again, Discovery has been removed 35 ls 36 history 37 history 5 38 history -d 36 39 history 5[[email protected] ~]# history -c //Delete all history [email protected] ~]# history 31 history[[email protected] ~]# history -a[[email protected] ~]# [[email protected] ~]# cd /[[email protected] /]# ls123 boot dev lib media proc selinux tmp varabc data etc lib64 mnt Root srv usr xxlbin data1 home lost+found opt sbin sys uzz[[email protected] /]# cd [[email protected] ~]# ls12 anaconda-ks.cfg -n uzz123 ett.txt oldboy xxl123456 install.log oldboy.txt xxl.txtabc install.log.syslog session192.168.80.1280320.log[[email protected] ~]# history 31 history 32 history -a 33 cd / 34 ls 35 cd 36 ls 37 history[[email protected] ~]# !33 //repeating 33rd Historical Command cd /[[email protected] /]# cd[[email protected] ~]# ls12 anaconda-ks.cfg -n uzz123 ett.txt oldboy xxl123456 install.log oldboy.txt xxl.txtabc install.log.syslog session192.168.80.1280320.log[[email protected] ~]# !! //repeatedly executes the previous command ls12 anaconda-ks.cfg -n uzz123 ett.txt oldboy xxl123456 install.log oldboy.txt xxl.txtabc install.log.syslog session192.168.80.1280320.log[[email protected] ~]# ! c //repeatedly executes the last command preceded by C cd[[email Protected] ~]# [[email protected] ~]# history 2 cd / 3 ls 4 cd 5 ls 6 history 7 cd / 8 cd 9 ls 10 cd 11 history[[email protected] ~]# ls12 anaconda-ks.cfg -n uzz123 ett.txt oldboy xxl123456 install.log oldboy.txt xxl.txtabc install.log.syslog session192.168.80.1280320.log[[email protected] ~]# ls12 anaconda-ks.cfg -n uzz123 ett.txt oldboy xxl123456 install.log oldboy.txt xxl.txtabc install.log.syslog session192.168.80.1280320.log[[email protected] ~]# history //The default repeatedly executed commands are not logged     4  CD 5 ls 6 history 7 cd / 8 cd 9 ls 10 cd 11 history 12 ls 13 History[[email protected] ~]# cd /[[email protected] /]# [[email protected] /]# history 6 history 7 cd / 8 cd 9 ls 10 cd 11 history 12 ls 13 history 14 cd / 15 history[[email protected] /]# export histcontrol= "Ignorespace" //setting a command that starts with a space is not logged [[email protected] /]# cd [[email protected] ~]# [[Email protected] ~]# history 8 cd 9 ls 10 cd 11 history 12 ls 13 history 14 cd / 15 history 16 export histcontrol= "Ignorespace" 17 history[[email protected] ~]#
2. Command completion and path completion
There are many commands and paths in Linux, and it is unavoidable to forget that the command completion feature provided by the Bash shell compensates for this flaw. Just give the first few letters of the command, bash looks for a file named after the given command name from left to right based on the path defined by the PATH environment variable, and the first time you find the file to run.
Press the TAB key to complete automatically, if not yet complete, you can tap the TAB key, select the command to execute from the options given, or give some hints.
[[email protected] ~]# e //Input e press TAB to find a number of commands that begin with E, and then press TAB once to list all e2freefrag envsubst eu-objdumpe2fsck eqn eu-ranlibe2image eqn2graph eu-readelfe2label era_check eu-sizee2undo era_dump eu-stackecho era_invalidate eu-stringsed esac eu-stripeditdiff espdiff eu-unstripedquota ether-wake evalefibootmgr ethtool exegrep eu-addr2line execeject eu-ar execstackelif eu-elfcmp exitelinks eu-elflint expandelse eu-findtextrel exportenable eu-make-debug-archive exprenv eu-nm [[email protected] ~]# echo //input EC, press ENTER, display echo[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 /knocking Tab Completion
This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://xuxiaoliang.blog.51cto.com/10882951/1921930
Bash Shell Foundation feature theory + case study