Monitoring file changes in a real time is very easy to do task in Linux System.
Directory, files, logs, etc. Changes can be easily monitored in real time with the help of watch command.
Watch is easy to use program to monitor changes in file or directory in Linux. It’s come by pre installed in all debain and arch based Linux System.
Check Watch is in system or not
Execute below command to know watch command is properly working in your system or not.
$ watch -v
Right now 3.3.16 is the latest version of watch. May be when you reading these post version will be changed.
Monitor files in the current directory
To monitor real time changes in current directory simple execute below code it will automatically changes, when there is new directory or file created.
$ watch ls
Above screen will be change, when there is any changes appear in User Directory.
Monitor disk spaces and highlight the changes
Below commad highlight where ever there is changes in Filesystem, 1k-blocks, Used, Available, User and Mounted on in free disk space command.
$ watch -d df
Watch real time changes in text file
Below command display live changes in file.txt. When ever user edit in file every changes will display in screen.