Learn how to watch filesystem events in real time and trigger actions with a tiny, script-friendly tool. 14.06.2026 | reading time: 3 min When a file changes on a server, he often needs to know immediately; inotifywait turns the kernel's inotify hooks into a simple, scriptable stream of events so he can act the moment something happens. Hands-on watch example Create a test directory, start a monitor, then create files to see live events: ```bash mkdir -p /tmp/watchdir; inotifywait -m -e create -e modify -e delete /tmp/watchdir # In another shell: touch /tmp/watchdir/file.txt && echo hello > /tmp/watchdir/file.txt && rm /tmp/watchdir/file.txt # Expected output from the monitor: /tmp/watchdir CREATE file.txt /tmp/watchdir MODIFY file.txt /tmp/watchdir DELETE file.txt ``` A practical trigger script Use inotifywait in a script to react to new uploads; the example below waits for a new file and then runs a checksum and moves it: ```bash inotifywait -m -e close_write --format "%w%f" /var/incoming | while read FILE; do md5sum "$FILE" > "$FILE.md5" && mv "$FILE" /var/archive/; done ``` Options that matter Remember the essentials: use `-m` for continuous mode, `-r` to recurse into subdirectories, `-e` to limit events (create,modify,delete,close_write,move), `--format` to control the output for parsing, and `-t` to set a timeout when you need a bounded wait; combine with `--exclude` to ignore temp files. When to choose inotifywait Pick inotifywait when you need low-latency, kernel-driven notifications for single-host scripts or local automation; it is lightweight, reliable for most workloads, and integrates neatly into shell pipelines and systemd path units. Related commands and systems Beyond inotifywait, the inotify API powers larger tools: `inotifywatch` collects event statistics, `fanotify` provides a different API for antivirus and global access control, and systemd.path units can start services from path changes; choose the tool that fits scope and permission needs. Next steps Try wiring inotifywait into a backup script or a CI job that picks up artifacts; practice will reveal edge cases like filename limits and race conditions, and mastering these patterns prepares him for broader Linux administration challenges and certifications like CompTIA Linux+ or LPIC-1 with focused exam prep at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. filesystem utilities scripting troubleshooting backup