Category: Linux

Find files created/changed

Want to know the php files that were created/changed in the last 24h ?
Easy, just run this:

 find /var/www/vhosts/ -type f -mtime -1 -name '*.php' -print

This will print out the last files created or changed in the last 24hours under the folder vhost (recursively).

You can even create a cronjob to do that every day at (ex: 1:00h) and send the output to a email address, just create a cronjob:

crontab -e

now create the job:

 0 1 * * * find /var/www/vhosts/ -type f -mtime -1 -name '*.php' -print | mail -s "Alert - find new files"

Reset Linux file permissions

So, you broke up the file tree permissions, someone did it for you or sent you a tar/zip with all chmod 777.

There is how to get those perms back on track:

For directories only you can do this.

find /some/place -type d -exec chmod 775 {} \;

For files only do this.

find /some/place -type f -exec chmod 664 {} \;