Our Leadership team is attending CloudFest 2026, from Mar 22 - April 8. Schedule a Connect

Our Leadership team is attending CloudFest 2026, from Mar 22 - April 8.

Discuss MSP growth, DevOps excellence, and Cloud Transformation. Available for 1:1 meetings, Schedule a Connect

  • DevOps
    Case Study

    How we helped a development company rebuild DevOps for efficiency and scale.

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How a US hosting leader scaled with us!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    Enabling financial grade platforms through strategic cloud modernisation.

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Managed Services Overview
  • Kubernetes Consulting
  • DevOps as a Service
  • Infrastructure Monitoring
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Services
  • Managed Services

aws partneraws advanced partner
LinkedInFacebookXInstagramYouTube
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

Monitor changes made to a file using auditd

Author Profile
Ruben Roy
  • 4 min read
Monitor changes made to a file using auditd

Generating audio, please wait...

Modern Linux kernel comes with auditd daemon. It is responsible for writing audit records to the disk. During startup, the rules in /etc/audit.rules are read by this daemon. You can open /etc/audit.rules file and make changes such as setup audit file log location and other option. The default file is good enough to get started with auditd.

ausearch is a simple command line tool used to search the audit daemon log files based on events and different search criteria such as event identifier, key identifier, CPU architecture, command name, hostname, group name or group ID, syscall, messages and beyond. It also accepts raw data from stdin.

By default, ausearch queries the /var/log/audit/audit.log file, which you can view just like any other text file.

In order to use audit facility you need to use following utilities

auditctl    –   A command to assist controlling the kernels audit system. You can get status, and add or delete rules into kernel audit system. Setting a watch on a file is accomplished using this command

ausearch –   A command that can query the audit daemon logs based for events based on different search criteria.

aureport   –  A tool that produces summary reports of the audit system logs.

Step1: Install audit package

The audit package contains the user space utilities for storing and searching the audit records generate by the audit subsystem in the Linux 2.6 kernel.

root@sage16:/home/jackson# sudo apt-get update
root@sage16:/home/jackson# sudo apt-get install auditd
Reading package lists... Done
Building dependency tree      
Reading state information... Done

Now start service:

root@sage16:/home/jackson# /etc/init.d/auditd start 
[ ok ] Starting auditd (via systemctl): auditd.service.

How do I set a watch on a file for auditing?

Let us say you would like to audit a /etc/passwd file. You need to type command as follows:

#  auditctl -w /etc/passwd -p war -k password-file

Where,

Promotional banner

-w /etc/passwd –   Insert a watch for the file system object at given path i.e. watch file called /etc/passwd

-p war –  Set permissions filter for a file system watch. It can be r for read, w for write, x for execute, a for append.

-k password-file – Set a filter key on a /etc/passwd file (watch). The password-file is a filterkey (string of text that can be up to 31 bytes long). It can uniquely identify the audit records produced by the watch. You need  to use password-file string or phrase while searching audit logs.

For Example let us see how do we find out who changed or accessed a file /etc/passwd?

Use ausearch command as follows:

# ausearch -f /etc/passwd 
OR 
# ausearch -f /etc/passwd | less 
OR 
# ausearch -f /etc/passwd -i | less

For example I have created the file and set a watchlog as  shown below

#  sudo auditctl -w /home/jackson/audit_test -p war

Now I am using ausearch command find out who changed or accessed a file

ausearch -f /home/jackson/audit_test

Please see the output as follows.

time->Sat May 18 18:36:57 2019 
type=PROCTITLE msg=audit(1558184817.050:210): proctitle="gedit" 
type=PATH msg=audit(1558184817.050:210): item=0 name="/home/jackson/audit_test" inode=13336667 dev=00:35 mode=0100664 ouid=10231 ogid=10231 rdev=00:00 nametype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0 
type=CWD msg=audit(1558184817.050:210): cwd="/home/jackson" 
type=SYSCALL msg=audit(1558184817.050:210): arch=c000003e syscall=2 success=yes exit=20 a0=1b57bc0 a1=0 a2=0 a3=aaaaaaaaaaaaaaab items=1 ppid=1568 pid=4084 auid=4294967295 uid=10231 gid=10231 euid=10231 suid=10231 fsuid=10231 egid=10231 sgid=10231 fsgid=10231 tty=(none) ses=4294967295 comm="pool" exe="/usr/bin/gedit" key=(null)

Find User Activity in Auditd Log File, Please note that the -ua is used to pass a username.

# ausearch -ua jackson 

OR 

# ausearch -ua ruben -i

Please see the output added below. From the results, we can check which file has been edited by ‘jackson’

---- time->Sat May 18 18:59:45 2019

type=USER_END msg=audit(1558186185.996:50): pid=10976 uid=10221 auid=4294967295 ses=4294967295 msg='op=PAM:session_close acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/25 res=success'

----

time->Sat May 18 18:59:45 2019

type=CRED_DISP msg=audit(1558186185.996:51): pid=10976 uid=10221 auid=4294967295 ses=4294967295 msg='op=PAM:setcred acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/25 res=success'

Conclusion

So in this blog we discussed about the auditctl command  that assist controlling the kernels audit system. You can get status, and add or delete rules into kernel audit system. Setting a watch on a file is accomplished using this command. Also, using ausearch command we  can query the audit daemon logs based for events based on different search criteria.

server monitoring

  • Security
  • Server Monitoring
Promotional banner
Promotional banner

Applying Kernel Patch Without Rebooting

Applying Kernel Patch Without Rebooting
  • Server Monitoring
logo

Best practices to reduce customer complaints in shared hosting support

Best practices to reduce customer complaints in shared hosting support
  • Customer Care
logo

To check which all ports are listening (Introducing Four Linux Commands)

To check which all ports are listening (Introducing Four Linux Commands)
  • Linux
logo

Why should you think of outsourcing backup management?

Why should you think of outsourcing backup management?
  • Backup management
logo
Monitor changes made to a file using auditd

Posts by Ruben Roy

Ruben Roy