1、history命令用於顯示歷史執行過的命令
執行 history命令能顯示出當前使用者在本地計算機中執行過的最近 1000 條命令記錄。
如果覺得 1000 不夠用,還可以自定義/etc/profile 檔案中的histsize 變數值。
在使用 history 命令時,如果使用-c 引數則會清空所有的命令歷史記錄。
history命令:
history //顯示終端執行過的命令
history 10
//顯示最近10條終端執行過的命令
ctrl+r //
搜尋已經執行過的命令,它可以你寫命令時自動補全
2.修改history命令顯示屬性
vi ~/.bash_profilehistfilesize=2000
//定義了在檔案 ~/.bash_history 中儲存命令的記錄總數
histsize=2000
//定義history 命令輸出的記錄數
histtimeformat="
%y-%m-%d:%h-%m-%s:`whoami`: "//
記錄每條歷史命令的執行時間和執行者,顯示結果為21 2019-02-16:09-06-01:edwetl: vi .profile
histtimeformat='
<%f %t> : '//
顯示結果為 21 <2019-02-16 09:06:01> : vi .profile
3.history的歷史命令儲存在~/.bash_history 檔案中.
done
Linux檢視歷史命令
今天面試問到怎麼檢視歷史命令,我說用上方向鍵把面試官逗笑了,特此查詢記錄一下。linux中,bash輸入的命令記錄,通過history檢視所有歷史記錄。記錄會存在.bash history 或者root bash history 中,通過echo histfile 使用此命令檢視環境變數 histo...
Linux命令 檢視歷史,並顯示操作時間
最終效果如下 在這裡插入描述 linux下可輸入 history 檢視已執行命令歷史。正常是不帶操作時間的,預設只顯示序號和命令。要想顯示操作時間需要做如下配置。臨時顯示 如需臨時顯示執行時間則輸入 export histtimeformat f t 1永久生效 如需永久顯示執行時間可通過編輯名為 ...
Linux檢視歷史命令 history
root linux history n root linux history c root linux history raw histfiles 引數 n 數字,意思是 要列出最近的 n 筆命令列表 的意思!c 將目前的 shell 中的所有 history 內容全部消除 a 將目前新增的 hi...