View history Commands
History #显示所有历史命令history #显示最近的10条命令
To view the number of default history command bars:
Echo $HISTSIZE
This environment variable is defined in/etc/profile.
LS!407 # re-calls a positive number in history No. 407 command command LS!-4 #重新调用历史中的倒数第4条命令
Historical commands are stored in two parts:. Bash_history and Memory
When you exit normally, the in-memory history is stored in the. bash_history
Executes the first last command starting with shut
!shut
Execute the previous command containing go
!? Go
1: Up and down key turn 2:ctrl+p3:!! 4:! -1
Ctrl+r
Use parameters from several commands that you have just executed, but the commands are different: (Take the command LS for example)
ls esc. #按完ESC, press directly after loosening. ls alt+.ls !^ # The first parameter of the previous command ls !$ #表示上一个命令的最后一个参数ls !:2 #调用上一个命令中的第二个参数ls !* #调用上一个命令中的所有参数ls !444:2 #调用history中第444个命令的第2个参数ls !444:* #调用第444个命令中的所有参数
The Alt method is not useful in the non-host and screen
history -c #清除内存中的命令历史rm ./bash_history #删除历史文件中的内容HISTSIZE =0 # Clears the memory history by modifying the history command bar number
history [-c][-d offset]history -a|n|r|w [filename]history -p|s arg [arg ... ]history -d num #删除指定的条目history -a #强制内存中的history追加到./bash history -n #常用于多用户登陆 in the _history file, loading the contents of the history file that have not been loaded into the history list history -r # read from .bash_history reads the history -w #将当前内存中的历史, appends to the specified file, and defaults to. Bash_ historyhistory -p rm -rf / #只显示命令, not added to the history list history -s rm - rf / #不显示命令, but adds the command to the history list
history-p & History-s
[[email protected] wu]# history-p rm-rf m rm-rfm[[email protected] wu]# History 3 262 ls-d * 263 ll-d * hist Ory 3[[email protected] wu]# history-s rm-rf/[[email protected] wu]# History 3 3 265 rm-rf/266 Tory 3
History Command parsing