Linux系统定制History输出格式
Linux系统使用History命令来查看系统的运行记录,从而找出一些问题。但是History输出的数据中常常没有时间等信息。本文就来教大家Linux系统如何定制History输出格式。

具体方法如下
以root用户登录服务器,在/etc/profile.d/下新建一个文件history_command
vim /etc/profile.c/history_command
export HISTFILE=$HOME/.bash_history
export HISTSIZE=1200
export HISTFILESIZE=1200
export HISTCONTROL=ignoredups
export HISTTIMEFORMAT=“`whoami` %F %T ”
shopt -s histappend
typeset -r HISTTIMEFORMAT
source /etc/profile.c/history_command 使其生效,再敲history命令看看:
#history 5
1008 root 2015-09-11 08:54:20 vim /etc/profile
1009 root 2015-09-11 09:13:17 history | less
1010 root 2015-09-11 09:15:49 vim /etc/profile
1011 root 2015-09-11 09:43:20 cat /etc/profile.d/history_command
1012 root 2015-09-11 09:44:59 history 5
时间已经有了,/etc/profile和/etc/profile.d/下的文件会在用户interactive login的时候自动执行,所以用户登录机器后每敲一个命令都会被记录到HISTFILE指定的文件中,而且是以追加的方式写入的。
配置中最关键的地方是export HISTTIMEFORMAT=“whoami %F %T ” , 这一行指定history的输出格式。
以上就是Linux系统如何定制History输出格式的介绍了,这样就能让History显示更多自己想要知道的信息了。
网站标题:Linux系统定制History输出格式
文章地址:http://www.tyjierui.cn/article/cogdggi.html
其他资讯
- vue2.x怎么通过后端接口代理获取qq音乐api的数据-创新互联
- springcloud(五):Swagger2的集成-创新互联
- 闹钟AlarmAndMusic如何实现滑动调整时间和页面旋转风车效果
- 质数javascript,质数的定义
- Linuxatoi:实现字符串到数字的转换(linuxatoi)
- python安装tkwindows?(Python安装教程)
- 欧美插画网站推荐?(原画场景设计素材网站推荐,国外设计素材网站推荐)
- 如何获取SQL数据库的用户名和密码?(连接sql数据库用户名和密码是多少)
- python定义为int
- Linux服务器如何获取所有域名?(linux服务器获取所有域名)


咨询
建站咨询
