查看sudo的history:配置sudolog
sudo 权力很大,但责任更重大!
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记录日志-客Ren
以下操作请使用sudo或在root权限下小心进行!
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 ~/.bashrc
#在底下加一行
alias sudolog='cat /var/log/sudo.log'
#使其生效
source ~/.bashrc
以后就可以使用sudolog来查看用sudo都执行过什么了
#切换至root账户
sudo su - root
#执行
echo '' > /var/log/sudo.log
呃,这里不明白的是为什么有sudo权限的账户执行echo '' > /var/log/sudo.log
会提示权限不够 : /var/log/sudo.log
希望有知道的大佬指教一下