在/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
转载于:https://blog.51cto.com/xiaofengmo/1752412