↑ ↓ select, Enter open, Esc close

#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
harmlessFilesystem

Recursively delete all files with a given name

$find /var/www/vhosts/example.com/httpdocs -type f -name 'error_log' -print -delete
destructiveFilesystem

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}'
harmlessFilesystem

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 {} +
cautionImages and performance

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 {} +
cautionImages and performance

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
harmlessText processing

Delete empty directories recursively

$find /var/www/vhosts/example.com/httpdocs -mindepth 1 -type d -empty -print -delete
destructiveFilesystem

Delete files older than X days

$find /var/backups/example.com -type f -name '*.tar.gz' -mtime +30 -print -delete
destructiveFilesystem

Find broken symbolic links

$find /var/www/vhosts/example.com -xtype l -ls
harmlessFilesystem

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
harmlessFilesystem

Find empty directories

$find /var/www/vhosts/example.com/httpdocs -mindepth 1 -type d -empty
harmlessFilesystem

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
harmlessFilesystem

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
harmlessFilesystem

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
harmlessFilesystem

Find files with the SUID or SGID bit

#find / -xdev \( -perm -4000 -o -perm -2000 \) -type f -exec ls -l {} + 2>/dev/null
harmlessPermissions and ownership

Find files with the wrong owner in a webspace

#find /var/www/vhosts/example.com/httpdocs ! -user webuser -ls
harmlessPermissions and ownership

Find files without a valid owner

#find /var/www -xdev \( -nouser -o -nogroup \) -ls 2>/dev/null
harmlessPermissions and ownership

Find hidden PHP files in the web directory

$find /var/www/vhosts/example.com/httpdocs -type f -name '.*.php' -ls
harmlessSecurity

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
harmlessImages and performance

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
harmlessSecurity

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
harmlessSecurity

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
harmlessFilesystem

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
harmlessImages and performance

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
harmlessImages and performance

Find world-writable files and directories

$find /var/www/vhosts -xdev -perm -0002 ! -type l -ls 2>/dev/null
harmlessSecurity

Find world-writable files and directories

$find /var/www/vhosts -xdev -perm -0002 ! -type l -ls 2>/dev/null
harmlessPermissions and ownership

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
harmlessSecurity

List all symbolic links with their targets

$find /var/www/vhosts/example.com -type l -printf '%p -> %l\n'
harmlessFilesystem

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 {} +
cautionImages and performance

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 {} +
cautionImages and performance

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 {} +
cautionImages and performance

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 {} +
cautionPermissions and ownership

Set all directories to 755 recursively

$find /var/www/vhosts/example.com/httpdocs -type d -exec chmod 755 {} +
cautionPermissions and ownership

Set all files to 644 recursively

$find /var/www/vhosts/example.com/httpdocs -type f -exec chmod 644 {} +
cautionPermissions and ownership

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.