7.history命令
history命令用於顯示歷史執行過的命令,格式為“history [-c]”。
history命令應該是作者最喜歡的命令。執行history命令能顯示出當前用戶在本地計算機中執行過的最近1000條命令記錄。如果覺得1000不夠用,還可以自定義/etc/profile文件中的HISTSIZE變量值。在使用history命令時,如果使用-c參數則會清空所有的命令歷史記錄。還可以使用“!編碼數字”的方式來重復執行某一次的命令。總之,history命令有很多有趣的玩法等待您去開發。
[root@linuxprobe ~]# history 1 tar xzvf VMwareTools-9.9.0-2304977.tar.gz 2 cd vmware-tools-distrib/ 3 ls 4 ./vmware-install.pl -d 5 reboot 6 df -h 7 cd /run/media/ 8 ls 9 cd root/ 10 ls 11 cd VMware\ Tools/ 12 ls 13 cp VMwareTools-9.9.0-2304977.tar.gz /home 14 cd /home 15 ls 16 tar xzvf VMwareTools-9.9.0-2304977.tar.gz 17 cd vmware-tools-distrib/ 18 ls 19 ./vmware-install.pl -d 20 reboot 21 history [root@linuxprobe ~]# !15 anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Desktop Downloads Music Public Videos
歷史命令會被保存到用戶家目錄中的.bash_history文件中。Linux系統中以點(.)開頭的文件均代表隱藏文件,這些文件大多數為系統服務文件,可以用cat命令查看其文件內容。
[root@linuxprobe ~]# cat ~/.bash_history
要清空當前用戶在本機上執行的Linux命令歷史記錄信息,可執行如下命令:
[root@linuxprobe ~]# history -c
8.sosreport命令
sosreport命令用於收集系統配置及架構信息並輸出診斷文檔,格式為sosreport。
當Linux系統出現故障需要聯系技術支持人員時,大多數時候都要先使用這個命令來簡單收集系統的運行狀態和服務配置信息,以便讓技術支持人員能夠遠程解決一些小問題,亦或讓他們能提前了解某些復雜問題。在下面的輸出信息中,加粗的部分是收集好的資料壓縮文件以及校驗碼,將其發送給技術支持人員即可:
[root@linuxprobe ~]# sosreport sosreport (version 3.0) This command will collect diagnostic and configuration information from this Red Hat Enterprise Linux system and installed applications. An archive containing the collected information will be generated in /var/tmp and may be provided to a Red Hat support representative. Any information provided to Red Hat will be treated in accordance with the published support policies at: https://access.redhat.com/support/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Press ENTER to continue, or CTRL-C to quit. 此處敲擊回車來確認收集信息 Please enter your first initial and last name [linuxprobe.com]:此處敲擊回車來確認主機編號 Please enter the case number that you are generating this report for:此處敲擊回車來確認主機編號 Running plugins. Please wait ... Running 70/70: yum... Creating compressed archive... Your sosreport has been generated and saved in: /var/tmp/sosreport-linuxprobe.com-20170905230631.tar.xz The checksum is: 79436cdf791327040efde48c452c6322 Please send this file to your support representative.