Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Installation And Startup Of SELinux auditd Logging System

The auditd daemon is a critical component of the SELinux (Security-Enhanced Linux) system. It is responsible for logging events and monitoring system activities to help you identify any security-related incidents. In this tutorial, we'll cover the installation, configuration, and startup of the auditd logging system on Linux distributions.

  • Installation:

The auditd daemon is part of the audit package. To install it, use the package manager specific to your Linux distribution:

  • For Debian/Ubuntu-based systems:

    sudo apt-get update
    sudo apt-get install auditd
    
  • For RHEL/CentOS-based systems:

    sudo yum install audit
    
  • For openSUSE-based systems:

    sudo zypper install audit
    
  • Configuration:

The primary configuration file for auditd is /etc/audit/auditd.conf. This file contains various settings such as log file location, disk space management, and log rotation. Open the file using your preferred text editor:

sudo nano /etc/audit/auditd.conf

Edit the configuration options as needed. Some key settings include:

  • log_file: Specifies the location of the log file (default: /var/log/audit/audit.log).
  • num_logs: Determines the number of log files to retain (default: 5).
  • max_log_file: Sets the maximum size (in MB) of each log file (default: 6).
  • max_log_file_action: Defines the action to take when a log file reaches its maximum size (default: ROTATE).

Save the changes and exit the editor.

  • Rules configuration:

Audit rules define the specific events and system activities to be monitored by auditd. The rules are stored in the /etc/audit/rules.d/ directory, typically in a file named audit.rules. To create or modify the rules, open the file using a text editor:

sudo nano /etc/audit/rules.d/audit.rules

Add or edit the rules as needed. Some examples of audit rules include:

  • Monitor file access for a specific file:

    -w /path/to/file -p rwxa -k file_access
    
  • Log all system calls made by a specific user:

    -a always,exit -F arch=b64 -F euid=1000 -S all -k user_activity
    

Save the changes and exit the editor.

  • Starting and managing the auditd service:

After configuring auditd, you need to start and enable the service:

  • For systemd-based systems:

    sudo systemctl start auditd
    sudo systemctl enable auditd
    
  • For SysV init-based systems:

    sudo service auditd start
    sudo chkconfig auditd on
    

To check the status of the auditd service, run:

sudo systemctl status auditd

To restart the auditd service after making changes to the configuration or rules, use the following command:

sudo systemctl restart auditd
  • Log analysis:

auditd logs are stored in the location specified in the configuration file (default: /var/log/audit/audit.log). To analyze the logs, you can use the ausearch and aureport tools:

  • Search for specific events using ausearch:

    sudo ausearch -k key_name
    
  • Generate a summary report using aureport:

    sudo aureport
    
  1. Setting up auditd in SELinux on Unix-like systems: auditd is the userspace component for the Linux Auditing System. Install and configure it on SELinux-enabled systems.

    sudo yum install audit
    
  2. How to install and configure SELinux auditd: Install the auditd package and configure it by editing the /etc/audit/auditd.conf file. Example:

    sudo nano /etc/audit/auditd.conf
    
  3. Starting and stopping auditd in SELinux: Start and stop the auditd service using the following commands:

    sudo systemctl start auditd
    sudo systemctl stop auditd
    
  4. Auditd service management in Linux: Manage the auditd service with systemctl. Restart the service:

    sudo systemctl restart auditd
    
  5. Configuring audit rules for SELinux auditd: Configure audit rules in /etc/audit/rules.d/audit.rules. Example:

    sudo nano /etc/audit/rules.d/audit.rules
    
  6. Interpreting auditd logs in SELinux: View auditd logs using ausearch or aureport. Example:

    ausearch -m AVC
    
  7. Troubleshooting auditd startup issues in SELinux: Troubleshoot startup issues by checking the auditd service status, reviewing logs, and ensuring proper SELinux policy configuration.

    journalctl -xe | grep auditd