使用`history`可以输出你曾经输入过的历史命令。例如

[root@server ~]# history | more
ls
cd 
vi test.sh

  

但是这里只显示了命令,没有显示执行命令的时间。

因为保存历史命令的`~/.bash_history`文件里并没有保存时间。

 

加时间戳方法:

echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile   

然后`source`一下就可以了

source /etc/profile

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案