Linux系統自定義命令歷史的格式


在/etc/profile文件最後加上以下內容,這個文件是全局的,對所有用戶都生效,命令歷史記錄默認寫在家目錄下的.bash_history文件中

export HISTFILESIZE=10000000

export HISTTIMEFORMAT="%x %T "

PROMPT_COMMAND="history -a;$PROMPT_COMMAND"


當然,你也可以寫在自己的家目錄下的.bashrc文件中,這是對當前用戶生效


效果如下:

[hadoop@vm02 ~]$ history
    1  03/18/2016 09:54:00 exit
    2  03/18/2016 09:54:00 ssh-keygen
    3  03/18/2016 09:54:00 ssh-copy-id -i .ssh/id_rsa.pub 192.168.1.100
    4  03/18/2016 09:54:00 ls
    5  03/18/2016 09:54:00 ssh 192.168.1.100
    6  03/18/2016 09:54:00 ls
    7  03/18/2016 09:54:00 vim /etc/hosts
    8  03/18/2016 09:54:00 ls
    9  03/18/2016 09:54:00 clear
   10  03/18/2016 09:54:00 ls
   11  03/18/2016 09:54:00 cd /usr/local/hadoop/
   12  03/18/2016 09:54:00 ls
   13  03/18/2016 09:54:00 cd etc/
   14  03/18/2016 09:54:00 ls
   15  03/18/2016 09:54:00 cd hadoop/
   16  03/18/2016 09:54:00 ls
   17  03/18/2016 09:54:00 vim core-site.xml
   18  03/18/2016 09:54:00 ls
   19  03/18/2016 09:54:00 cd hdfs-site.xml
   20  03/18/2016 09:54:00 vim hdfs-site.xml
   21  03/18/2016 09:54:00 vim hdfs-site.xml
   22  03/18/2016 09:54:00 ls
   23  03/18/2016 09:54:00 exit
   24  03/18/2016 09:54:00 /usr/local/hadoop/sbin/start-dfs.sh
   25  03/18/2016 09:54:00 jps
   26  03/18/2016 09:54:00 /usr/local/hadoop/sbin/start-dfs.sh
   27  03/18/2016 09:54:00 exit


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章