下载安卓APP箭头
箭头给我发消息

客服QQ:3315713922

Linux系统教程_Linux系统怎样去定制History输出格式呢?

作者:Linux系统教程     来源: www.kokojia.com点击数:583发布时间: 2015-09-17 09:34:07

标签: Linux系统教程Linux系统入门学习

Linux的系统历史记录命令检查记录系统的运行情况,以确定一些问题。然而,输出数据历史是经常没有时间信息。本文就来教大家Linux系统教程如何定制History输出格式。

 

Linux系统教程_Linux系统怎样去定制History输出格式呢?

 

  linux系统教程具体方法如下
  以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系统教程介绍了如何自定义历史的输出格式,这样就可以使他们想知道的历史显示更多的信息。了解更多相关资讯或视频教程欢迎进入课课家查询详情。

赞(28)
踩(1)
分享到:
华为认证网络工程师 HCIE直播课视频教程