CentOS-解决CentOS 7 history命令不显示操作记录的时间和用户身份问题
来源:互联网 发布:刘邦历史书籍 知乎 编辑:程序博客网 时间:2024/05/22 10:26
CentOS 6中history命令显示操作命令的时间和用户身份
[root@node02 ~]# history
294 2017-01-06 16:46:48 root clear
295 2017-01-06 16:46:50 root ll
296 2017-01-06 16:46:52 root cat hostname.sh
297 2017-01-06 16:46:56 root cat nginxlog_cut.sh
298 2017-01-06 16:47:29 root clear
299 2017-01-06 16:47:34 root history
[root@node02 ~]# cat /etc/RedHat-release
CentOS release 6.6 (Final)
[root@node02 ~]#
而CentOS7中,history命令中不显示操作命令的时间和用户身份
[root@localhost data]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@localhost data]# history -n 10
[root@localhost data]# history 10
1268 \
1269 history
1270 cat /etc/redhat-release
1271 clear
1272 cat /etc/redhat-release
1273 history
1274 clear
1275 cat /etc/redhat-release
1276 history -n 10
1277 history 10
[root@localhost data]#
解决该问题只需要在/etc/profile中添加如下变量即可:
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S `whoami` "
然后运行source /etc/profile命令即可,注意引号中的空格
[root@localhost data]# history 10
1273 2017-01-05 19:40:18 root history
1274 2017-01-05 19:40:27 root clear
1275 2017-01-05 19:40:29 root cat /etc/redhat-release
1276 2017-01-05 19:40:35 root history -n 10
1277 2017-01-05 19:40:39 root history 10
1278 2017-01-05 19:41:12 root cat /etc/profile
1279 2017-01-05 19:42:16 root vim /etc/profile
1280 2017-01-05 19:42:26 root source /etc/profile
1281 2017-01-05 19:42:28 root history
1282 2017-01-05 19:42:42 root history 10
[root@localhost data]#
history命令的用法及参数usage: history [-c] [-d offset] [n] or history-anrw [filename] or history -ps arg [arg...]
参数:
n :数字,要列出最近的若干命令列表
-c :将目前的 shell中的所有 history内容全部消除
-a :将目前新增的 history指令新增入 histfiles中,若没有加 histfiles,则预设写入 ~/.bash_history
-r :将 histfiles的内容读到目前这个 shell的 history记忆中
-w :将目前的 history记忆内容写入 histfiles
- CentOS-解决CentOS 7 history命令不显示操作记录的时间和用户身份问题
- centos配置history记录每个用户执行过的命令
- centos配置history记录每个用户执行过的命令
- CentOS配置history记录每个用户执行过的命令
- CentOS - history 显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- ubuntu History命令显示操作时间、用户和登录IP
- centos history显示命令执行时间、执行用户,执行IP
- linux的history命令显示操作用户、显示操作时间、命令
- history 命令显示时间记录
- history命令显示操作时间
- Linux 配置 history 命令显示操作时间、用户和登录 IP
- centos解决eth0 ip不显示问题
- 解决Centos系统ifconfig不显示ipv4的问题
- CentOS下的history命令
- linux 如何让linux的history命令显示时间记录
- GITLAB修改分支权限
- Android kotlin入门与基础语法二
- 编译时注解解析
- Node -- 模块机制
- try,catch
- CentOS-解决CentOS 7 history命令不显示操作记录的时间和用户身份问题
- profiles 配置
- java现在还很热!
- Python-unittest测试框架
- kali linux 开机输入密码无法进入界面
- SonarQube代码质量管理平台安装与使用
- 设计模式之模板方法模式
- 谁动了我的特征?——sklearn特征转换行为全记录
- javascript eval函数解析json数据时为什加上圆括号eval("("+data+")")