• 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. CentOS / RHEL : How to create a Thinly Provisioned Logical Volume
  2. crontab error : “You (user) are not allowed to access to (crontab) because of pam configuration.”
  3. Linux File/Directory Permissions cheat sheet
  4. Difference Between Qemu and KVM
  5. Linux “seq” Command Examples
  6. Unable To Extend LVM File System with Associated Snapshot in CentOS/RHEL
  7. How to enable additional scsi logging in CentOS/RHEL
  8. How to Mirror Swap, Boot and Root Partions in CentOS/RHEL 7 Using mdadm Utility
  9. CentOS / RHEL 7 : Understanding Kexec and Kdump
  10. “device-mapper: resume ioctl failed: Invalid argument” – error on running lvcreate/lvresize/lvextend

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright