+
docker
esbuild
objc
+
sublime
+
โˆˆ
+
+
+
โˆฉ
+
+
โІ
html
+
soap
?
+
apex
jenkins
scipy
c
+
nest
backbone
yarn
matplotlib
+
+
+
termux
+
sublime
gentoo
+
+
+
0b
+
+
+
+
$
+
asm
jenkins
mint
+
++
+
eclipse
arch
keras
+
nomad
+
yarn
+
supabase
==
julia
ractive
+
pinecone
c#
++
+
xml
ubuntu
bash
+
rollup
//
+
+
rb
+
+
+
nest
laravel
goland
!==
+
rails
+
npm
android
Back to Blog
๐Ÿ” System Auditing with auditd on AlmaLinux: Track Everything Like a Security Pro!
almalinux auditd security

๐Ÿ” System Auditing with auditd on AlmaLinux: Track Everything Like a Security Pro!

Published Sep 7, 2025

Master system auditing with auditd on AlmaLinux! Learn to monitor file access, track user actions, and detect security breaches with easy examples. Perfect for beginners wanting enterprise-level auditing! ๐Ÿ›ก๏ธ

5 min read
0 views
Table of Contents

๐Ÿ” System Auditing with auditd on AlmaLinux: Track Everything Like a Security Pro!

Ever wondered who deleted that important file at 3 AM? ๐Ÿ•ต๏ธ Or need to prove your system is compliant with security standards? Maybe you want to catch that sneaky process accessing sensitive data? Welcome to the world of auditd - your systemโ€™s security camera that sees EVERYTHING! Today, weโ€™re turning your AlmaLinux system into a forensic powerhouse! ๐Ÿ”ฌ

๐Ÿค” Why is System Auditing Important?

Imagine having a security guard who never sleeps, never takes breaks, and remembers every single thing that happens on your system. Thatโ€™s auditd! Itโ€™s like having a time machine for your system events! โฐ

Hereโ€™s why auditd is absolutely essential:

  • ๐Ÿ” Detect security breaches - Know immediately when someoneโ€™s snooping
  • ๐Ÿ“œ Compliance requirements - Meet PCI-DSS, HIPAA, and other standards
  • ๐Ÿ•ต๏ธ Forensic investigations - Find out exactly what happened and when
  • ๐Ÿ‘ค Track user activities - Monitor whoโ€™s doing what on your system
  • ๐Ÿ“ File integrity monitoring - Know when critical files are modified
  • ๐Ÿšจ Real-time alerts - Get notified of suspicious activities instantly
  • ๐Ÿ“Š Create audit trails - Build unalterable records for legal purposes

๐ŸŽฏ What You Need

Before we start building your auditing fortress, letโ€™s check what you need! Super simple requirements:

  • โœ… AlmaLinux installed (any recent version)
  • โœ… Root or sudo access (we need the power! ๐Ÿ’ช)
  • โœ… About 25 minutes of your time
  • โœ… Basic understanding of file permissions
  • โœ… Curiosity about whatโ€™s happening on your system
  • โœ… Coffee ready (this is exciting stuff! โ˜•)

๐Ÿ“ Step 1: Install and Enable auditd

Letโ€™s get our audit system up and running! Most AlmaLinux installations include auditd, but letโ€™s make sure!

# Check if auditd is installed
rpm -qa | grep audit
# Should show audit packages

# If not installed, install it now
sudo dnf install -y audit
# Installs the audit daemon and tools

# Enable and start the audit service
sudo systemctl enable --now auditd
# Starts auditd and enables it at boot

# Check audit service status
sudo systemctl status auditd
# Should show "active (running)" in green!

Letโ€™s verify everything is working! ๐ŸŽ‰

# Check audit system status
sudo auditctl -s
# Shows if auditing is enabled

# View current audit rules
sudo auditctl -l
# Lists all active audit rules

# Check audit log location
ls -la /var/log/audit/audit.log
# Default audit log file

๐Ÿ”ง Step 2: Configure Basic Audit Rules

Time to tell auditd what to watch! Weโ€™ll start with essential security monitoring.

# First, let's see the main config file
sudo nano /etc/audit/auditd.conf
# Main daemon configuration

# Important settings to check:
log_file = /var/log/audit/audit.log
log_format = ENRICHED
log_group = root
priority_boost = 4
flush = INCREMENTAL_ASYNC
freq = 50
max_log_file = 8
num_logs = 5

Now letโ€™s add some powerful audit rules! ๐Ÿš€

# Monitor login attempts
sudo auditctl -w /var/log/lastlog -p wa -k user_login
# Tracks all login activity

# Monitor password changes
sudo auditctl -w /etc/passwd -p wa -k passwd_changes
sudo auditctl -w /etc/shadow -p wa -k shadow_changes
# Watches password files for modifications

# Monitor sudo commands
sudo auditctl -w /etc/sudoers -p wa -k sudoers_changes
sudo auditctl -a always,exit -F path=/usr/bin/sudo -F perm=x -k sudo_commands
# Tracks sudo usage and configuration changes

๐ŸŒŸ Step 3: Create Persistent Audit Rules

Letโ€™s make sure our rules survive reboots! Persistence is key! ๐Ÿ”‘

# Edit the audit rules file
sudo nano /etc/audit/rules.d/audit.rules
# This file loads at boot

# Add these comprehensive rules:

Add this complete ruleset for robust auditing:

# First, delete all existing rules
-D

# Set buffer size
-b 8192

# Failure handling (1 = silent, 2 = panic)
-f 1

# Monitor authentication events
-w /var/log/lastlog -p wa -k logins
-w /var/run/faillock -p wa -k logins
-w /var/log/tallylog -p wa -k logins

# Monitor user and group changes
-w /etc/passwd -p wa -k users
-w /etc/group -p wa -k groups
-w /etc/shadow -p wa -k passwords
-w /etc/gshadow -p wa -k passwords
-w /etc/security/opasswd -p wa -k passwords

# Monitor sudo activities
-w /etc/sudoers -p wa -k sudo_config
-w /etc/sudoers.d/ -p wa -k sudo_config

# Monitor SSH configuration
-w /etc/ssh/sshd_config -p wa -k sshd_config
-w /root/.ssh -p wa -k ssh_keys
-w /home -p wa -k ssh_keys -F path=/home/*/.ssh

# Monitor system calls for suspicious activity
-a always,exit -F arch=b64 -S execve -k command_execution
-a always,exit -F arch=b64 -S socket -S connect -k network_connections

# Monitor file deletions
-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid>=1000 -F auid!=4294967295 -k file_deletion

# Monitor privilege escalation
-a always,exit -F arch=b64 -S setuid -S setgid -S setreuid -S setregid -k privilege_escalation
-a always,exit -F arch=b64 -S sethostname -S setdomainname -k system_info_change

Now reload the rules:

# Load rules from file
sudo augenrules --load
# Processes all rule files

# Verify rules are loaded
sudo auditctl -l | head -20
# Shows first 20 rules

# Make rules immutable (optional, requires reboot to change)
# sudo auditctl -e 2
# Locks configuration until reboot

โœ… Step 4: Search and Analyze Audit Logs

Now for the detective work! Letโ€™s learn to find what weโ€™re looking for! ๐Ÿ”

# Search for all events from a specific user
sudo ausearch -ua username
# Shows all actions by that user

# Search for events in the last hour
sudo ausearch -ts recent
# Shows recent activity

# Search for specific event types
sudo ausearch -k passwd_changes
# Uses the key we defined earlier

# Search for failed operations
sudo ausearch --success no
# Shows all failed attempts

# Generate a report of all events
sudo aureport
# Creates a summary report

Letโ€™s explore more powerful searches! ๐Ÿ’ช

# Get authentication report
sudo aureport -au
# Shows all authentication attempts

# File modification report
sudo aureport -f
# Lists all file access events

# Command execution report
sudo aureport -x
# Shows executed commands

# Anomaly report
sudo aureport -n
# Network-related anomalies

# Failed events summary
sudo aureport --failed
# All failed operations

๐ŸŽฎ Quick Examples

Letโ€™s see auditd in action with real-world scenarios! ๐Ÿš€

Example 1: Monitor a Sensitive Directory

# Watch everything in /etc/ssl
sudo auditctl -w /etc/ssl -p rwxa -k ssl_access
# Tracks all access to SSL certificates

# Test it - access a file
sudo cat /etc/ssl/certs/ca-bundle.crt > /dev/null

# Search for the event
sudo ausearch -k ssl_access -ts recent
# Shows your access attempt!

# Get detailed info with interpretation
sudo ausearch -k ssl_access -ts recent --interpret
# Human-readable output

Example 2: Track Command Execution

# Monitor specific dangerous commands
sudo auditctl -a always,exit -F path=/usr/bin/rm -F perm=x -k file_deletion_commands
sudo auditctl -a always,exit -F path=/usr/bin/dd -F perm=x -k disk_operations
sudo auditctl -a always,exit -F path=/usr/sbin/fdisk -F perm=x -k disk_partitioning

# Test by running rm
touch /tmp/test-file
rm /tmp/test-file

# Find the event
sudo ausearch -k file_deletion_commands -ts recent
# Shows who ran rm and when

# Get execution report
sudo aureport -x --summary
# Shows command execution statistics

Example 3: Real-time Monitoring

# Watch audit log in real-time
sudo tail -f /var/log/audit/audit.log
# Shows events as they happen

# Better: Use formatted real-time monitoring
sudo ausearch -ts recent -k passwd_changes --format text | tail -f
# Prettier real-time view

# Create a monitoring script
cat << 'EOF' > ~/audit-monitor.sh
#!/bin/bash
echo "๐Ÿ” Monitoring system events..."
while true; do
    sudo ausearch -ts '1 minute ago' --format text 2>/dev/null | grep -v "no matches"
    sleep 10
done
EOF
chmod +x ~/audit-monitor.sh
# Run with: ~/audit-monitor.sh

๐Ÿšจ Fix Common Problems

Donโ€™t worry if things seem complex at first! Here are solutions to common issues! ๐Ÿ’ก

Problem 1: โ€œAudit log growing too largeโ€

# Solution: Configure log rotation
sudo nano /etc/audit/auditd.conf

# Adjust these settings:
max_log_file = 50  # Max size in MB
num_logs = 10      # Number of logs to keep
max_log_file_action = ROTATE  # What to do when full

# Force rotation now
sudo service auditd rotate
# Rotates the current log

# Check disk usage
du -sh /var/log/audit/
# Shows total audit log size

# Clean old logs if needed
sudo find /var/log/audit/ -name "*.log" -mtime +30 -delete
# Deletes logs older than 30 days

Problem 2: โ€œToo many audit events, hard to find important onesโ€

# Solution: Filter your rules better
# Remove a noisy rule
sudo auditctl -W /path/to/noisy/directory -p rwxa -k noisy_key
# Capital -W removes the watch

# Add more specific rules
sudo auditctl -w /etc/passwd -p wa -k passwd_changes -F uid!=0
# Only non-root changes

# Use aureport for summaries
sudo aureport --summary
# High-level overview

# Create custom filtered reports
sudo ausearch -k important_events | aureport -f --summary
# Focused reporting

Problem 3: โ€œCanโ€™t understand audit log entriesโ€

# Solution: Use interpretation tools
# Use --interpret flag
sudo ausearch -ts today --interpret
# Converts UIDs to usernames, etc.

# Use ausearch with formatting
sudo ausearch -ts recent --format csv > audit_report.csv
# Export to CSV for analysis

# Create readable reports
sudo aureport -x -ts today --summary --interpret
# Human-friendly summary

# Install additional tools for visualization
sudo dnf install -y audit-viewer
# GUI tool for audit logs (if desktop available)

Problem 4: โ€œAudit rules not persisting after rebootโ€

# Solution: Check rules location and loading
# Verify rules file exists
ls -la /etc/audit/rules.d/
# Should show .rules files

# Check if rules are loading
sudo augenrules --check
# Shows what would be loaded

# Rebuild and load rules
sudo augenrules --load
# Regenerates and loads rules

# Verify after reboot
sudo systemctl status auditd
sudo auditctl -l | wc -l
# Should show your rules count

๐Ÿ“‹ Simple Commands Summary

Your auditd command cheat sheet - bookmark this! ๐Ÿ“Œ

CommandWhat It DoesExample
auditctl -lList all rulessudo auditctl -l
auditctl -wAdd file watchsudo auditctl -w /etc/passwd -p wa -k passwd
auditctl -WRemove file watchsudo auditctl -W /etc/passwd
ausearchSearch audit logssudo ausearch -k passwd_changes
aureportGenerate reportssudo aureport --summary
augenrulesLoad rules from filessudo augenrules --load
ausyscallShow syscall namesausyscall --dump
aulastShow last loginssudo aulast
auvirtVirtualization eventssudo auvirt --summary

๐Ÿ’ก Tips for Success

Ready to become an audit ninja? Here are pro tips thatโ€™ll make you unstoppable! ๐Ÿฅท

Strategic Rule Planning

  • ๐ŸŽฏ Start with critical files only
  • ๐Ÿ“Š Monitor trends before adding more rules
  • ๐Ÿ”„ Review and refine rules monthly
  • ๐Ÿ“ Document why each rule exists

Performance Optimization

# Increase buffer for busy systems
-b 16384  # In audit.rules

# Use syscall filtering wisely
-a never,exit -F arch=b64 -S open -F dir=/tmp -F success=0
# Ignore failed /tmp opens

# Exclude noisy processes
-a never,user -F subj_type=crond_t
# Skip cron job auditing

Compliance Templates

  • ๐Ÿ“‹ PCI-DSS: Focus on cardholder data access
  • ๐Ÿฅ HIPAA: Monitor all PHI file access
  • ๐Ÿ›๏ธ Government: Track all privileged operations
  • ๐Ÿข SOX: Audit financial system changes

Alert Integration

# Create alert script
cat << 'EOF' > /usr/local/bin/audit-alert.sh
#!/bin/bash
ausearch -ts '5 minutes ago' -k critical_changes | \
  grep -q "type=SYSCALL" && \
  echo "Critical change detected!" | \
  mail -s "Audit Alert" [email protected]
EOF

# Add to cron for regular checks
echo "*/5 * * * * /usr/local/bin/audit-alert.sh" | sudo crontab -
# Checks every 5 minutes

๐Ÿ† What You Learned

Outstanding work! Look at what youโ€™ve mastered! ๐ŸŽŠ Youโ€™re now an audit expert:

  • โœ… Installed and configured auditd for comprehensive monitoring
  • โœ… Created powerful audit rules for files and system calls
  • โœ… Set up persistent rules that survive reboots
  • โœ… Mastered searching and analyzing audit logs
  • โœ… Generated detailed audit reports
  • โœ… Implemented real-time monitoring
  • โœ… Solved common auditing challenges
  • โœ… Optimized audit performance
  • โœ… Built compliance-ready audit trails
  • โœ… Created a forensic-ready system

๐ŸŽฏ Why This Matters

Youโ€™ve just implemented enterprise-grade security auditing! ๐Ÿ›ก๏ธ Your AlmaLinux system is now a fortress that tracks every significant event. No unauthorized change goes unnoticed. No security breach happens without leaving evidence.

This isnโ€™t just about catching bad guys - itโ€™s about understanding your system deeply, proving compliance, and having the confidence that comes from knowing exactly whatโ€™s happening on your servers. You can now answer questions like โ€œWho accessed this file?โ€ or โ€œWhat commands were run last Tuesday?โ€ with absolute certainty.

Youโ€™re not just an administrator anymore - youโ€™re a security professional with the tools to protect, investigate, and prove. Your audit logs are legal-grade evidence. Your monitoring is enterprise-ready. Youโ€™ve got the power! ๐Ÿ’ช

Keep auditing, keep securing, and remember - the best security professionals donโ€™t just respond to incidents, they prevent them! Youโ€™ve got this! โญ

Happy auditing, AlmaLinux security champion! ๐Ÿ™Œ