We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.
今天發現沒法查看歷史的sudo命令,故有此一文
參考配置sudo記錄日誌-客Renhtml
如下操做請使用sudo或在root權限下當心進行!web
vim /etc/rsyslog.conf
#在文件底部添加一行
local2.debug /var/log/sudo.log
visudo #添加3行 Defaults logfile=/var/log/sudo.log Defaults loglinelen=0 Defaults !syslog
touch /var/log/sudo.log
systemctl restart rsyslog
有效!vim
vim ~/.bashrc #在底下加一行 alias sudolog='cat /var/log/sudo.log' #使其生效 source ~/.bashrc
之後就能夠使用sudolog來查看用sudo都執行過什麼了
bash
#切換至root帳戶 sudo su - root #執行 echo '' > /var/log/sudo.log
呃,這裏不明白的是爲何有sudo權限的帳戶執行echo '' > /var/log/sudo.log
會提示權限不夠 : /var/log/sudo.log
但願有知道的大佬指教一下svg