centos删除history历史记录
时间: 2023-08-16 11:09:19 浏览: 201
要删除CentOS系统中的历史记录,可以使用以下命令:
1. 清空当前用户的历史记录:
```
history -c
```
2. 永久清除所有用户的历史记录:
```
cat /dev/null > ~/.bash_history && history -c && exit
```
执行完第二条命令后,系统会自动退出当前用户,重新登录后所有用户的历史记录就会被清空。请注意,这个命令会删除所有用户的历史记录,包括root用户的历史记录,因此请谨慎使用。
相关问题
centos删除root下970行-1000行的history历史记录
要删除CentOS系统中root用户下970行到1000行的历史记录,可以使用以下命令:
1. 查看root用户的历史记录行数:
```
history | wc -l
```
2. 删除970行到1000行的历史记录:
```
history -d 970-1000
```
请注意,这个命令只会删除root用户的历史记录中970行到1000行的记录,不会清空所有用户的历史记录。如果您想清空所有用户的历史记录,请参考我之前给出的命令。
centos7 清除历史记录
您可以使用以下命令清除CentOS 7上的历史记录:
1. 清除最近使用的命令和搜索历史记录:
```
history -c
```
2. 清除bash历史记录文件:
```
cat /dev/null > ~/.bash_history && history -c && exit
```
3. 清除所有用户的bash历史记录文件:
```
cat /dev/null > /root/.bash_history && cat /dev/null > /home/username/.bash_history && history -c && exit
```
请注意,这些操作将永久删除历史记录,无法恢复。
阅读全文
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![](https://img-home.csdnimg.cn/images/20250102104920.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20250102104920.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)