• 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. How to set nproc (Hard and Soft) Values in CentOS / RHEL 5,6,7
  2. firewall-offline-cmd Command Examples in Linux
  3. How to Set CPU Affinity for SYSTEMD Process in CentOS/RHEL 7
  4. gcov Command Examples in Linux
  5. How to Create and Manage Storage Domains in RedHat Virtualization (RHV)
  6. mt Command Examples in Linux
  7. How To Create Virtual Data Optimizer(VD0) in CentOS/RHEL 7 and 8
  8. How to remove the noatime mount option from root mount point without reboot (CentOS/RHEL)
  9. How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
  10. mate-search-tool Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “az storage blob” Command Examples (Manage blob storage containers and objects in Azure)
  • “az storage account” Command Examples (Manage storage accounts in Azure)
  • “az sshkey” Command Examples (Manage ssh public keys with virtual machines)
  • “az redis” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright