• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
白_胖_子
Linux学习的生活就是这么朴实无华且枯燥
博客园    首页    新随笔    联系   管理    订阅  订阅

history历史记录增加显示时间和用户

history只有行号不方便便

增加现实时间和用户更清楚

[08:50:43 root@c7-1-54 ~]#HISTTIMEFORMAT="%F %T `whoami`  "
[08:51:03 root@c7-1-54 ~]#history
    1  2021-03-03 08:48:12 root  ifconfig
    2  2021-03-03 08:48:12 root  hostname -I
    3  2021-03-03 08:48:12 root  cat /etc/hostname
    4  2021-03-03 08:48:12 root  /etc/hostname < C7
    5  2021-03-03 08:48:12 root  echo C7 < /etc/hostname
    6  2021-03-03 08:48:12 root  cat /etc/hostname\
    7  2021-03-03 08:48:12 root  cat /etc/hostname
    8  2021-03-03 08:48:12 root  vi /etc/hostname

将如上配置写入配置文件永久生效

[08:59:15 root@C8-3-55 ~]#vim .bash_profile

修改配置文件

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

export HISTTIMEFORMAT="%F %T `whoami`  "  ##在末尾添加格式化语句

使文件立即生效

 1057  2021-03-03 08:59:12 root  . .bash_profile
 1058  2021-03-03 08:59:15 root  history
* * * 胖并快乐着的死肥宅 * * *
posted @ 2021-03-03 22:08  白_胖_子  阅读(146)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3