Linux的history命令

本文介绍了如何使用Bash shell管理历史命令,包括查看历史记录、清空历史记录、设置历史命令的显示格式等技巧,并详细解释了配置参数的作用。

1)查看历史命令
[root@shell ~]# history
2)历史命令存放在哪个文件中?
~username/.bash_history
[root@shell ~]# ls /root/.bash_history
默认最多保存1000条历史命令
[root@shell ~]# set | grep -i hist BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
HISTCONTROL=ignoredups
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
3)清空历史命令
[root@rui ~]# history -c
4) 设置历史查看格式
[root@rui ~]# HISTTIMEFORMAT=" %F %T `whoami`----"
[root@rui ~]# history
    2   2017-02-23 15:32:04 root----history
    3   2017-02-23 15:33:04 root----HISTTIMEFORMAT=" %F ----"
    4   2017-02-23 15:33:09 root----history
    5   2017-02-23 15:33:35 root----man HISTTIMEFORMAT
    6   2017-02-23 15:37:38 root----HISTTIMEFORMAT=" %F %T `whoami`----"
    7   2017-02-23 15:37:42 root----history

转载于:https://www.cnblogs.com/ruigu/p/8603176.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值