日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
解決CentOS7history命令不顯示操作記錄的時間和用戶身份問題

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 ~]#

而CentOS 7中,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命令輸出結(jié)果格式完美解決,如果要清除歷史記錄,可以運用history -c,具體history用法如下:
history命令的用法及參數(shù)usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
參數(shù):
n :數(shù)字,要列出最近的若干命令列表
-c :將目前的 shell 中的所有 history 內(nèi)容全部消除
-a :將目前新增的 history 指令新增入 histfiles 中,若沒有加 histfiles ,則預設寫入 ~/.bash_history
-r :將 histfiles 的內(nèi)容讀到目前這個 shell 的 history 記憶中
-w :將目前的 history 記憶內(nèi)容寫入 histfiles


網(wǎng)頁標題:解決CentOS7history命令不顯示操作記錄的時間和用戶身份問題
網(wǎng)頁URL:http://m.5511xx.com/article/dpoipsi.html