記錄所有使用者登入系統的任何操作日誌,以便有據可查。
1.編輯/etc/profile
檔案。
#vim /etc/profil
2. 在其後新增如下內容
historyuser=`whoami
`user_ip=`who -u am i 2>/dev/null| awk
''|sed -e '
s/[()]//g'`
if [ "
$user_ip
" = "" ]; then
user_ip=`hostname`fi
if [ ! -d /var/log/history ]; then
mkdir /var/log/history
chmod
777 /var/log/history
fiif [ ! -d /var/log/history/$ ]; then
mkdir /var/log/history/$
chmod
300 /var/log/history/$
fiexport histsize=4096
dt=`date +"
%y%m%d_%h:%m:%s"`
export histfile="
/var/log/history/$/$@$_$dt
"chmod
600 /var/log/history/$/*
history* 2>/dev/null
3. 載入檔案生效
#source /etc/profile
/var/log/history 日誌的存放位置,該目錄下以每個使用者為名建立乙個資料夾,每次使用者退出後都會產生以使用者名稱、登入ip、時間的日誌檔案,以及使用者本次的所有操作。
root使用者不記錄在此。
linux中history記錄所有使用者操作命令
工作中遇到了使用者誤刪除事件,為了以防萬一考慮記錄所用使用者的操作指令。找到了下面解決方案,測試可行。mkdir p var log usermonitor 建立使用者審計檔案存放目錄和審計日誌檔案echo 20200402 var log usermonitor usermonitor.log 建...
linux 記錄所有系統使用者bash操作日誌
記錄所有使用者登入系統的任何操作日誌,以便有據可查。1.編輯 etc profile檔案 vim etc profilehistory user whoami user ip who u am i 2 dev null awk sed e s g if user ip then user ip ho...
linux檢視所有使用者
檢視所有使用者 linux裡,並沒有像windows的net user,net localgroup這些方便的命令來治理使用者。xwindows介面的就不說了。的工具或命令 groupadd 注 新增使用者組 groupdel 注 刪除使用者組 groupmod 注 修改使用者組 groups 注 ...