Linux file operations

Useful file operation commands

Linux Search Files

Find all files modified at date:
find ./ -type f —name “*.php” newermt “2017-10-14”
Find all files modified at date and time:
find ./ -type f —name “*.php” -newermt “2017-10-14 10:21:00”
Find all modified files between dates:
find ./ -type f —name “*.php” -newermt “2017-10-14 10:21:00” \! -newermt “2017-10-14 10:40:00”
Delete all files modified between dates:
find ./ -type f -newermt “2017-10-14 10:21:00” \! -newermt “2017-10-14 10:40:00” -exec rm {} +
Backup root directory excluding home, tmp, etc:
sudo tar --exclude='/proc' --exclude='/home' --exclude='/tmp' --exclude='/var/web-cache' --exclude='/boot' -zcvf yyyy-mm-dd_root.tgz /
Archive by 7z excluding directories
sudo 7z a -r 2017_11_14-root.7z /* '-xr!/boot' '-xr!/proc' '-xr!/tmp' '-xr!/var/web-cache' '-xr!/home' -spf

rsync – a fast, versatile, remote (and local) file-copying tool

Copy files by rsync over SSH from server to local machine:

rsync -avz -e “ssh -o StrictHostKeyChecking=no -o UserKnownHostFile=/dev/null” —progress username@198.0.0.0:/var/cache/apt/archives/*.deb /home/username/Downloads