#find
34 one-liners with this tag.
All one-liners tagged find
Find a file by name
$find /var/www/vhosts -iname '*wp-config*' 2>/dev/null
Recursively delete all files with a given name
$find /var/www/vhosts/example.com/httpdocs -type f -name 'error_log' -print -delete
Calculate the total size of all files of one type
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -iname '*.mp4' -printf '%s\n' | awk '{s+=$1; n++} END {printf "%d Dateien, %.1f MB\n", n, s/1048576}'
Convert images to AVIF recursively
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.avif" ] || avifenc -s 6 "$f" "$f.avif" >/dev/null; done' sh {} +
Convert images to WebP recursively
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.webp" ] || cwebp -quiet -q 80 "$f" -o "$f.webp"; done' sh {} +
Count and sort lines across many files
$find /var/www/vhosts/example.com/httpdocs/wp-content/themes -type f -name '*.php' -exec wc -l {} + | sort -rn | head -n 20
Delete empty directories recursively
$find /var/www/vhosts/example.com/httpdocs -mindepth 1 -type d -empty -print -delete
Delete files older than X days
$find /var/backups/example.com -type f -name '*.tar.gz' -mtime +30 -print -delete
Find broken symbolic links
$find /var/www/vhosts/example.com -xtype l -ls
Find duplicate files by checksum
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -size +0 -exec md5sum {} + | sort | uniq -w32 --all-repeated=separate
Find empty directories
$find /var/www/vhosts/example.com/httpdocs -mindepth 1 -type d -empty
Find files modified between two dates
$find /var/www/vhosts/example.com/httpdocs -type f -newermt '2026-10-01' ! -newermt '2026-10-08' -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort
Find files modified in the last minutes
$find /var/www/vhosts/example.com/httpdocs -type f -mmin -60 -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r
Find files older than X days
$find /var/www/vhosts/example.com -type f -mtime +30 -printf '%TY-%Tm-%Td %p\n' | sort | head -100
Find files with the SUID or SGID bit
#find / -xdev \( -perm -4000 -o -perm -2000 \) -type f -exec ls -l {} + 2>/dev/null
Find files with the wrong owner in a webspace
#find /var/www/vhosts/example.com/httpdocs ! -user webuser -ls
Find files without a valid owner
#find /var/www -xdev \( -nouser -o -nogroup \) -ls 2>/dev/null
Find hidden PHP files in the web directory
$find /var/www/vhosts/example.com/httpdocs -type f -name '.*.php' -ls
Find large images in wp-content/uploads
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.webp' \) -size +500k -printf '%s\t%p\n' | sort -rn | head -50 | numfmt --field=1 --to=iec
Find PHP files in the WordPress uploads folder
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.php' -o -iname '*.phtml' -o -iname '*.php[0-9]' \) -ls
Find recently modified PHP files
$find /var/www/vhosts/example.com/httpdocs -type f -name '*.php' -mtime -7 -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r
Find the largest files in a directory
$find /var/www/vhosts -type f -size +500M -exec ls -lh {} + 2>/dev/null | sort -k5 -rh | head -20
Find unminified CSS and JS files
$find /var/www/vhosts/example.com/httpdocs/wp-content -type f \( -name '*.css' -o -name '*.js' \) ! -name '*.min.*' -size +20k -exec sh -c 'echo "$(wc -l < "$1") $1"' sh {} \; | awk -v n=200 '$1 > n' | sort -rn | head -30
Find web font files and their size
$find /var/www/vhosts/example.com/httpdocs/wp-content -type f \( -iname '*.woff2' -o -iname '*.woff' -o -iname '*.ttf' -o -iname '*.otf' -o -iname '*.eot' \) -printf '%s\t%p\n' | sort -rn | head -30 | numfmt --field=1 --to=iec
Find world-writable files and directories
$find /var/www/vhosts -xdev -perm -0002 ! -type l -ls 2>/dev/null
Find world-writable files and directories
$find /var/www/vhosts -xdev -perm -0002 ! -type l -ls 2>/dev/null
List all SSH keys authorized on the server
#find / -xdev -path '*/.ssh/authorized_keys' -type f -exec awk 'NF && !/^#/ {print FILENAME ": " $NF}' {} + 2>/dev/null
List all symbolic links with their targets
$find /var/www/vhosts/example.com -type l -printf '%p -> %l\n'
Optimize JPEG images losslessly with jpegoptim
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' \) -exec jpegoptim --strip-all --preserve {} +
Optimize PNG images losslessly with optipng
$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -iname '*.png' -exec optipng -o2 -strip all -preserve {} +
Precompress CSS, JS and SVG files with gzip and Brotli
$find /var/www/vhosts/example.com/httpdocs/wp-content/themes -type f \( -name '*.css' -o -name '*.js' -o -name '*.svg' \) -exec gzip -k -9 -f {} + -exec brotli -k -f {} +
Reset file ownership in a Plesk webspace to the subscription user
#find /var/www/vhosts/example.com/httpdocs -mindepth 1 -exec chown -h webuser:psacln {} +
Set all directories to 755 recursively
$find /var/www/vhosts/example.com/httpdocs -type d -exec chmod 755 {} +
Set all files to 644 recursively
$find /var/www/vhosts/example.com/httpdocs -type f -exec chmod 644 {} +