Linux history命令:顯示與管理歷史命令記錄
history命令來自于英文單詞歷史,其功能是用于顯示與管理歷史命令記錄。Linux系統(tǒng)默認(rèn)會記錄用戶所執(zhí)行過的所有命令,可以使用history命令查閱它們,也可以對其記錄進(jìn)行修改和刪除操作。
語法格式: history [參數(shù)]
常用參數(shù):
-a 寫入命令記錄
-c 清空命令記錄
-d 刪除指定序號的命令記錄
-n 讀取命令記錄
-r 讀取命令記錄到緩沖區(qū)
-s 將指定的命令添加到緩沖區(qū)
-w 將緩沖區(qū)信息寫入到歷史文件
參考實(shí)例
顯示執(zhí)行過的全部命令記錄:
[root@linuxcool ~]# history
1 vim /etc/sysconfig/network-scripts/ifcfg-ens160
2 reboot
3 vim /etc/sysconfig/network-scripts/ifcfg-ens160
4 vim /etc/yum.repos.d/rhel.repo
5 mkdir /media/cdrom
6 vim /etc/fstab
7 reboot
8 ping 192.168.10.10
9 dnf install httpd
10 exit
………………省略部分輸出信息………………
顯示執(zhí)行過的最近5條命令:
[root@linuxcool ~]# history 5
11 exit
12 ifconfig
13 vim /etc/hostname
14 reboot
15 history
將本次緩存區(qū)信息寫入到歷史文件中(~/.bash_history):
[root@linuxcool ~]# history -w
將歷史文件中的信息讀入到當(dāng)前緩沖區(qū)中:
[root@linuxcool ~]# history -r
將本次緩沖區(qū)信息追加寫入到歷史文件中(~/.bash_history):
[root@linuxcool ~]# history -a
清空本次緩沖區(qū)及歷史文件中的信息:
[root@linuxcool ~]# history -c
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)
- Linux wait命令:等待指令執(zhí)行完畢
- wait命令的功能是用于等待指令執(zhí)行完畢,常被用于Shell腳本中,用于等待某個指令執(zhí)行結(jié)束后返回終端,然后才會繼續(xù)執(zhí)行后面的指令。
- 03-19 關(guān)注:1