在 Debian 里,inotify 分两部分理解:
内核功能(inotify):
现代 Debian 内核默认已支持 inotify,不需要单独“安装”,只要内核 ≥ 2.6.13 即可(现在基本都是)。
用户态工具 / 开发库(常见你需要的是这些):
inotify-tools:提供 inotifywait、inotifywatch 命令libinotifytools0:运行库libinotify-dev:开发用头文件(写 C 程序才需要)sudo apt update
sudo apt install inotify-tools
安装后验证:
inotifywait --help
示例监听目录:
inotifywait -m /var/log
grep INOTIFY /boot/config-$(uname -r)
应看到:
CONFIG_INOTIFY_USER=y
sudo apt install libinotify-dev
调整 inotify 限制:
cat /proc/sys/fs/inotify/max_user_watches
临时修改:
sudo sysctl fs.inotify.max_user_watches=524288
永久生效:
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
如果你是想 监控文件变化 / 写脚本 / Docker 里用 inotify,可以告诉我具体场景,我可以给你更针对性的例子。