Repository navigation
Directory Watching
Home · Start Here · Reference Map
- How suspicious files are detected in risky paths.
- How to tune false positives with csf.fignore rules.
- How optional quarantine and watch mode behave.
Related guide: Security-Features-Guide
| Setting | Purpose |
|---|---|
LF_DIRWATCH |
Enable directory watching for suspicious files in /tmp, /dev/shm, and similar paths |
LF_DIRWATCH_FILE |
Watch a specific file or directory for any changes (md5sum-based) |
LF_DIRWATCH_DISABLE |
When enabled, quarantine suspicious files to a tarball and delete originals |
| File | Purpose |
|---|---|
/etc/csf/csf.fignore |
Ignore list for false-positive files and directories |
/usr/local/csf/tpl/filealert.txt |
Email template for suspicious file alerts |
/usr/local/csf/tpl/watchalert.txt |
Email template for watched file/directory change alerts |
/var/lib/csf/suspicious.tar |
Quarantine archive for removed suspicious files |
LFD checks /tmp, /dev/shm, and other pertinent directories for suspicious
files (typically script exploits). When a suspicious file is found, an alert
email is sent.
Only one alert per file is sent until LFD is restarted — if you remove a suspicious file, restart LFD to re-enable detection for that location.
When enabled, suspicious files are appended to a tarball at
/var/lib/csf/suspicious.tar and deleted from their original location.
Symlinks are simply removed.
To extract quarantined files preserving path and permissions:
tar -xpf /var/lib/csf/suspicious.tarThis option watches a particular file or directory for changes using an md5sum
match from the output of ls -laAR. It traverses directories if specified.
Changes trigger an alert using the watchalert.txt template.
Specify full paths to files LFD should ignore:
/tmp/clamav-somefile
Perl regular expression pattern matching is supported for entries containing
an asterisk (*):
/tmp/clamav.*
/tmp/.*\.wrk
Remember to escape special characters with a backslash (e.g., \., \?).
Entries without * use exact full-path matching.
You can also ignore files owned by a particular user:
user:bob
Note: Files owned by root are always ignored.
For information on perl regular expressions: see perldoc perlre.
- Enable
LF_DIRWATCHand keepLF_DIRWATCH_DISABLEoff initially (alert-only mode). - Reload:
csf -ra - Monitor alerts in
/var/log/lfd.logfor several days. - Add confirmed false positives to
csf.fignoreusing the most specific match possible. - Optionally enable
LF_DIRWATCH_DISABLEfor automatic quarantine once false positives are under control. - If using
LF_DIRWATCH_FILE, set it to a specific sensitive path (e.g.,/etc/passwd) and verify alerts fire on change.
- Not restarting LFD after removing a suspicious file — the same file path will not be re-alerted until LFD restarts.
-
Over-broad
csf.fignorepatterns — patterns like/tmp/.*effectively disable watching for that directory. -
Quarantine tarball growth — if
LF_DIRWATCH_DISABLEis enabled on a noisy server,/var/lib/csf/suspicious.tarcan grow indefinitely; monitor disk usage. -
ClamAV/scanner temp files — antivirus scanners commonly write to
/tmp; add their patterns tocsf.fignoreto avoid alert fatigue.
Last reviewed: 2026-02-27
← Previous: Process Tracking · Next: Advanced Allow/Deny Filters
- Security Features Guide
- Cloud & Container Hardening
- Automation & IaC
- IPv6 Deployment & Hardening
- IP Block Lists
- Reference Map
- Introduction
- csf Principles
- lfd Principles
- csf CLI Options
- lfd CLI Options
- Login Tracking
- Regex Custom Cookbook
- Script Email Alerts
- Process Tracking
- Directory Watching
- Advanced Filters
- Multiple Ethernet
- Generic Linux
- FTP Issues
- Messenger Service
- Block Reporting
- Port Flood
- Pre/Post Scripts
- Port Knocking
- Connection Limit
- Port/IP Redirect
- Integrated UI
- RESTRICT_SYSLOG
- Exim SMTP AUTH
- UI Skinning
- InterWorx
- CentOS Web Panel