How to find the list of newly created files and directories in Linux file system?
Linux is growing by leaps and bounds over the past decade and most of the organizations are intensely switching their production server environment to it nowadays. Today, We are showing an amazing trick to find the list of all newly created files and directories for the last day in your Linux file system, using “find” command.
The sole purpose of this tutorial is to find the record of newly created files and directories on your Linux machine. There are several benefits of tracking these records.
- Track the user activities and find files and directories created, edited, and modified by them.
- It is useful in identifying the malicious scripts and prevents the file system serving spam content.
- Tracking and null rooting of spam injected in your application or website by hackers.
- Better disk management and separate mounting of most used directories in your file system.
- In-depth monitoring and having a better action plan with the constantly changing behavior of your Linux server.
Find files & directories created in last 24 hours.
The following command will find files and directories created in last 24 hours under directory /home/ubuntu/, and directory /home/ubuntu/mail/ is excluded from the search. You can vary the value of directive cmin to modify your search time. Currently cmin directive is searching for files and directories created earlier than 1440 minutes on a Linux filesystem. The output of a command is stored in file /home/ubuntu/cfile.log & /home/ubuntu/cdir.log.
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type f -cmin -1440 >> /home/ubuntu/cfile.log
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type d -cmin -1440 >> /home/ubuntu/cdir.log
Find files & directories modified in last 24 hours.
The following command will find files and directories modified in last 24 hours under directory /home/ubuntu/, and directory /home/ubuntu/mail/ is excluded from the search. The output of a command is stored in file /home/ubuntu/mfile.log & /home/ubuntu/mdir.log.
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type f -mmin -1440 >> /home/ubuntu/mfile.log
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type d -mmin -1440 >> /home/ubuntu/mdir.log
Find files & directories accessed in last 24 hours.
The following command will find files and directories accessed in last 24 hours under directory /home/ubuntu/, and directory /home/ubuntu/mail/ is excluded from the search. The output of a command is stored in file /home/ubuntu/afile.log & /home/ubuntu/adir.log.
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type f -amin -1440 >> /home/ubuntu/afile.log
find /home/ubuntu -path /home/ubuntu/mail -prune -o -type d -amin -1440 >> /home/ubuntu/adir.log
Finally, We hope you guys find this tutorial useful and exciting. Stay tuned for more updates. Have a Good Day!
Recent Comments