栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

linux删除history记录

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux删除history记录

linux删除history记录

参考网址:

https://blog.csdn.net/Abysscarry/article/details/79700293?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164560805516780264015079%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=164560805516780264015079&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-2-79700293.pc_search_result_cache&utm_term=centos7%E5%88%A0%E9%99%A4%E6%8C%87%E5%AE%9Ahistory%E5%91%BD%E4%BB%A4&spm=1018.2226.3001.4187

查看命令帮助
help history

[root@VM-0-15-centos ~]# help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg…]
Display or manipulate the history list.

Display the history list with line numbers, prefixing each modified
entry with a `*'.  An argument of N lists only the last N entries.

Options:
  -c	clear the history list by deleting all of the entries
  -d offset	delete the history entry at offset OFFSET.

  -a	append history lines from this session to the history file
  -n	read all history lines not already read from the history file
  -r	read the history file and append the contents to the history
	list
  -w	write the current history to the history file
	and append them to the history list

  -p	perform history expansion on each ARG and display the result
	without storing it in the history list
  -s	append the ARGs to the history list as a single entry

If FILENAME is given, it is used as the history file.  Otherwise,
if $HISTFILE has a value, that is used, else ~/.bash_history.

If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry.  No time stamps are printed otherwise.

Exit Status:
Returns success unless an invalid option is given or an error occurs.
全部清除命令
history -c

说明:

一般我们已知的是history -c 命令,即清除所有历史记录
但是如果服务器用的是公司的,就不好执行这种粗暴的操作了。。

部分删除操作

1.*vim ~/.bash_history*
该文件即为历史记录存储文件,我们随意修改

2.修改后再次 history 查看,发现并没有变化。原因:缓存
执行:*history -r*
读取历史文件并将其内容添加到历史记录中,即重置文件里的内容到内存中,完成修改!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/748836.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号