• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to change the path of the auditd log file /var/log/audit/audit.log

by admin

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
Understanding System auditing with auditd
How to use auditd to monitor a specific SYSCALL
How to monitor the Mounting/Umounting of Mount Points Using Auditd on CentOS/RHEL 6,7
How to use auditd to monitor a file deletion in Linux

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. aspell: command not found
  2. inxi Command Examples in Linux
  3. Linux OS Service ‘named’
  4. How to configure VNC Server on CentOS/RHEL 6
  5. How to disable ICMP redirects on CentOS/RHEL
  6. Beginners Guide to Swap Space Management in Linux
  7. CentOS / RHEL 7 : How to configure kdump using GUI
  8. Linux rsync command with practical examples
  9. ipcrm: command not found
  10. nixos-rebuild Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright