El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Elastic Cloud Server/ Best Practices/ Setting Up an Application/ Using auditd to Record File Changes (Linux)

Using auditd to Record File Changes (Linux)

Updated on 2024-07-31 GMT+08:00

The auditd is a user-space component of the Linux audit system. It records operation logs, including file read/write and invoking records, in the OS, which can be used for audit if a fault occurs. This section uses CentOS 7.4 64bit as an example to describe how to install and configure auditd.

auditd-related Tool Commands and Configuration Files

Tool commands:

  • auditctl: controls the audit daemon in real time, such as adding rules.
  • aureport: checks and generates audit reports.
  • ausearch: searches for audit events.
  • auditspd: forwards event notifications to other applications instead of writing them to audit logs.
  • autrace: traces processes.

Configuration files:

  • /etc/audit/auditd.conf: specifies configuration file of auditd.
  • /etc/audit/rules.d/audit.rules: contains audit rules.
  • /etc/audit/audit.rules: records audit rules.

Procedure

Installing auditd

  1. Run the following command to install auditd:

    yum install -y auditd*

    NOTE:

    After auditd is installed for the first time, there are no audit rules by default. You can run the sudo auditctl -l command to query the audit rules.

  2. Run the following command to check the runtime status of auditd:

    service auditd status

    Figure 1 Runtime status

Configuring audit rules

  1. Run the following command to configure the monitoring file and change the directory:

    auditctl -w /etc/passwd -p rwxa

    where:

    • -w: specifies the file path to be monitored. The preceding command specifies the monitored file path /etc/passwd.
    • -p: specifies the access permission of the file or directory that triggers the audit.
    • rwxa: specifies trigger conditions. r indicates the read permission, w the write permission, x the execution permission, and a the attribute.
  2. Run the following commands to audit all accesses to /production:

    mkdir production

    auditctl -w /production/

  3. Run the following command to check configured rules:
    auditctl -l
    -w /etc/passwd -p rwxa
    -w /production -p rwxa
  4. After rules are added, run the following command to check the audit log:

    ausearch -f /etc/passwd

    Figure 2 Checking the audit log

    Figure 2 shows that the file is not modified. The parameters are described as follows:

    • time: audit time
    • name: audit object
    • cwd: current path
    • syscall: related system calls
    • auid: ID of the audited user
    • uid and gid: user ID and user group ID for accessing a file
    • comm: command for a user to access a file
    • exe: file path where the preceding command can be executed
  5. Run the following command to add a user test to the monitoring file:

    useradd test

  6. Run the following command to check the audit log again:

    ausearch -f /etc/passwd

    Figure 3 Checking the audit log again

    Figure 3 shows that /etc/passwd is modified by user root (uid=0, gid=0) in the /root directory at a specified time. The /etc/passwd file is accessed from /usr/bin/sudo.

  7. Run the following command to check whether the audit log contains any content:

    ausearch -f /production

  8. Run the following commands to change the directory permissions as user root and check the audit log again:

    chmod -R 777 /test/

    ausearch -f /test/

  9. Run the following command to view the audit report:

    aureport

    Figure 4 Viewing the audit report
  10. Run the following command to view the authorization failure details:

    aureport -au

    Figure 5 Viewing authorization failure details
  11. Run the following command to view all events related to account modifications:

    aureport -m

    Figure 6 Viewing account modification events
  12. (Optional) Run the following commands to clear the defined rules:

    auditctl -D

    auditctl -l

    Figure 7 Clearing defined rules

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback