Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Auditing is a crucial aspect of system administration that helps in tracking activities on a system, ensuring compliance, and detecting unauthorized access. In the Linux environment, auditing can be effectively performed using the Audit daemon, commonly known as "auditd." This tool provides comprehensive logging of system events and user activities.
Examples:
Installing Auditd:
To start using auditd, you need to ensure it is installed on your Linux system. Most Linux distributions provide it in their default repositories.
sudo apt-get update
sudo apt-get install auditd audispd-plugins
For Red Hat-based systems:
sudo yum install audit
Configuring Audit Rules:
Audit rules define what activities should be logged. These rules can be set in the /etc/audit/audit.rules
file. Below is an example of how to log all changes to the /etc/passwd
file:
-w /etc/passwd -p wa -k passwd_changes
Here, -w
specifies the file to watch, -p
sets the permissions (write and attribute change), and -k
is a key to identify the rule.
Starting and Enabling Auditd:
Once auditd is installed and configured, start the service and enable it to start on boot:
sudo systemctl start auditd
sudo systemctl enable auditd
Viewing Audit Logs:
Audit logs are stored in /var/log/audit/audit.log
. You can use ausearch
to query these logs. For example, to find all events related to the passwd_changes
key:
ausearch -k passwd_changes
Generating Audit Reports:
You can generate reports from audit logs using the aureport
command. For example, to generate a summary report of all login events:
aureport -l
Advanced Audit Rules:
To audit all commands executed by users, add the following rule:
-a always,exit -F arch=b64 -S execve -k user_commands
This rule logs every executed command (execve
system call) for 64-bit architecture.
By following these examples, you can set up a robust auditing system on your Linux environment, enabling you to monitor and log various system activities effectively. This setup is crucial for maintaining security and ensuring compliance with organizational policies.