An important task related to troubleshooting can arise from an understanding of activities commonly associated with the action of reading and writing files. Linux provides a simple utility for this. Known as auditd, this service (or daemon) starts during the boot process. Events are recorded to an associated log file found at /var/log/audit and as it runs in the background, you can check the current service status with below command in case of CentOS/RHEL 7 server:

# systemctl status auditd

 

It is possible to customize the auditing service and you can have direct access to manage the log file size, location, and associated attributes by accessing the following file with your favorite text editor:

# vi /etc/audit/auditd.conf

 

Changing the default log file location for auditd

 

1. In the auditd configuration file /etc/audit/auditd.conf, change the option log_file = /var/log/audit/audit.log so that it points to the new path, e. g.:

# vi /etc/audit/auditd.conf
log_file = /auditd_logs/audit.log

 

2. If you have the SELinux enabled, configure default SELinux file context labels for the new path and restore the security contexts accordingly:

# semanage fcontext -a -e /var/log/audit '/auditd_logs(/.*)?'
restorecon -Rv /auditd_logs

 

3. Restart the auditd service for the changes to take effect.

# service auditd restart         # For CentOS 5,6
# systemctl restart auditd       # For CentOS 7

 

Verify

You can check the new log file /auditd_logs/audit.log getting the new auditd logs written to. Also from now on, when using the ausearch command, add the -if or –input-logs switches:

# ausearch -if /auditd_logs/audit.log -m avc -i -ts recent

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)