简介
Linux中,bash输入的历史记录,会存在.bash_history(或者说root/bash_history)。
通过history查看。
可以看到,不仅可以输出正确的命令,还可以输入错误的(如abc),而且输出的是history之前所有的命令(including history),bash_history不是缓存文件,关机不会清除,文件会保存最近的N条命令,N=$HISTFILESIZE。
history和bash_histroy区别
history查看输入的命令,bash_history保存之前输入命令的文件(通常在用户目录下,如(home/user),通过cat .bash_history 或者vim / nano 查看。
但是history是实时的,会查看之前输入的所有命令,但是bash_history却只能查看到上次结束bash时之前的命令,就是说当前在bash输入的命令会在关闭terminal后存在bash_history中。
可以通过history -c删除bash历史, 但是.bash_history里仍会有历史记录
常用命令
history N 显示最近的N条命令,例如history 5
history -d N 删除第N条命令,这个N就是前面的编号,例如history -d 990
history -c 清空命令历史
history -a 将当前会话中的命令历史写入指定文件
echo $HISTFILE 使用此命令查看环境变量
root@33f:~# echo $HISTFILE
/root/.bash_history
echo $HISTFILESIZE 查看最大保存数目
export HISTTIMEFORMAT=’%F %T ’ 让history可以有时间戳显示
更多命令自行百度。
版权属于: 三三世界-百宝箱
本文链接: http://33f.net/os/bash_history.html
本文最后更新于2021年11月14日 ,已超过1173天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
Saved as a favorite, I like your website!
If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.
Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.
Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.
zh.us.to 有效
kms.03k.org 有效
kms.chinancce.com
kms.shuax.com 有效
kms.dwhd.org 有效
kms.luody.info 有效
kms.digiboy.ir 有效
kms.lotro.cc 有效
www.zgbs.cc 有效
cy2617.jios.org 有效
@ 权限问题,试试sudo 再加命令。
你好提示Permission denied 怎么办啊