当我们需要查看Linux下的操作记录时,就可以用history命令来查看历史记录
 
1、关闭history记录功能,如果不想让别人看到自己在Linux上的操作命令,可以用这个命令
set +o history  
2、打开history记录功能
set -o history
3、清空记录
history -c 记录被清空,重新登录后恢复。
4、删除记录文件,清空历史
rm -f $HOME/.bash_history 删除记录文件,清空历史。
5、显示最近 n 条命令
root@linux ~]# history 10
69 ls -al
70 cd linux
71 ls -al
72 cd ..
73 ls -al
74 ssh root@192.168.31.55
75 ssh root@192.168.31.11
76 git
77 python
78 history 10
6、命令语法
history [选项]
命令选项
| 选项 | 描述 | 
|---|---|
| -c | 清空当前历史命令 | 
| -a | 将历史命令缓冲区中命令写入历史命令文件中 | 
| -r | 将历史命令文件中的命令读入当前历史命令缓冲区 | 
| -w | 将当前历史命令缓冲区命令写入文件中 | 
| -n | 显示最近 n条命令 | 
| -d | 删除历史记录中的指定命令 |