CentOS 6.6 sudo日志配置
查询syslog和sudo软件是否已安装
[root@wangning ~]# rpm-qa|egrep "sudo|syslog"
rsyslog-5.8.10-8.el6.x86_64
sudo-1.8.6p3-15.el6.x86_64
配置/etc/sudoers文件
[root@wangning ~]# echo"Defaultslogfile=/var/log/sudo.log">>/etc/sudoers
[root@wangning ~]# tail -1/etc/sudoers
Defaults logfile=/var/log/sudo.log
检查sudoers文件语法是否正确
[root@wangning ~]# visudo -c
/etc/sudoers: parsed OK
配置/etc/rsyslog.conf文件
[root@wangning ~]# echo"local2.debug/var/log/sudo.log">>/etc/rsyslog.conf
[root@wangning ~]# tail -1/etc/rsyslog.conf
local2.debug /var/log/sudo.log
重启rsyslog服务
[root@wangning ~]#/etc/init.d/rsyslog restart
Shutting down systemlogger:[ OK ]
Starting system logger: [ OK ]
[root@wangning ~]# ll/var/log/sudo.log
-rw------- 1 root root 02017-06-03 16:14 /var/log/sudo.log
[oldboy@wangning ~]$ sudo ls /
[oldboy@wangning ~]$ sudo ls/var/log/sudo.log
[root@wangning ~]# cat/var/log/sudo.log
Jun 3 20:30:27 : user1 : TTY=pts/0 ;PWD=/home/oldboy ; USER=root ;
COMMAND=/bin/ls /
Jun 3 20:30:50 : user1 : command not allowed ;TTY=pts/0 ; PWD=/home/oldboy ;
USER=root ; COMMAND=/var/log/sudo.log
Jun 3 20:31:00 : user1 : TTY=pts/0 ;PWD=/home/oldboy ; USER=root ;
COMMAND=/bin/ls /var/log/sudo.log
Jun 3 20:31:10 : user1 : TTY=pts/0 ;PWD=/home/oldboy ; USER=root ;
COMMAND=/bin/ls -l /var/log/sudo.log
原文链接:https://www.f2er.com/centos/377059.html