↑ ↓ select, Enter open, Esc close

Filesystem

When the disk fills up or a file has to be found: commands for find, du, df, inodes and targeted cleanup on web servers.

40 one-liners: 23 harmless, 10 caution, 7 destructive

All Filesystem one-liners

Analyze disk usage interactively with ncdu

$ncdu -x /var
harmless

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

Check inode usage of filesystems

$df -ih -x tmpfs -x devtmpfs -x squashfs
harmless

Compare two directories for differences

$diff -rq /var/www/vhosts/example.com/httpdocs /var/www/vhosts/example.com/staging
harmless

Copy a directory with its contents

$cp -a -- /var/www/vhosts/example.com/httpdocs/wp-content/themes/mytheme /var/www/vhosts/example.com/httpdocs/wp-content/themes/mytheme-copy
caution

Copy a file

$cp -ip -- /var/www/vhosts/example.com/httpdocs/.htaccess /var/www/vhosts/example.com/private/htaccess-copy
caution

More power on the server

Does the optimization reach your visitors?

Faster database, more RAM, better caching: GENLOC.SEO measures whether it shows up in PageSpeed and Core Web Vitals. Free, for mobile and desktop.

by GENLOC.NETWORK, the team behind myline.de

Create a dated backup copy of a file

$cp -p -- /var/www/vhosts/example.com/httpdocs/.htaccess /var/www/vhosts/example.com/httpdocs/.htaccess.bak-$(date +%F-%H%M)
caution

Create a directory including parent folders

$mkdir -p -- /var/www/vhosts/example.com/private/backups/2026
caution

Create or repoint a symbolic link

$ln -sfn -- /var/www/vhosts/example.com/releases/2026-10-10 /var/www/vhosts/example.com/current
caution

Delete a directory with all its contents

$rm -rI -- /var/www/vhosts/example.com/httpdocs/old
destructive

Delete a file

$rm -i -- /var/www/vhosts/example.com/httpdocs/old.zip
destructive

Delete empty directories recursively

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

Delete files older than X days

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

Empty a file without deleting it

$truncate -s 0 -- /var/www/vhosts/example.com/logs/error_log
destructive

Extract a ZIP archive into a directory

$unzip -q /var/www/vhosts/example.com/private/upload.zip -d /var/www/vhosts/example.com/private/upload
caution

Find a file by name

$find /var/www/vhosts -iname '*wp-config*' 2>/dev/null
harmless

Find broken symbolic links

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

Find deleted files still held open

#lsof -nP +L1
harmless

Find directories with the most files

$du --inodes -x -d 1 /var/www/vhosts 2>/dev/null | sort -rn | head -20
harmless

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
harmless

Find empty directories

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

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
harmless

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
harmless

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
harmless

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
harmless

Find which filesystem a directory is on

$findmnt -T /var/www/vhosts
harmless

List all symbolic links with their targets

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

List directory contents with permissions and sizes

$ls -lAh --group-directories-first -- /var/www/vhosts/example.com/httpdocs
harmless

List disks and partitions

$lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,UUID
harmless

Move a file to another directory

$mv -i -- /var/www/vhosts/example.com/httpdocs/old.zip /var/www/vhosts/example.com/private/
caution

Pack a directory into a ZIP archive

$cd /var/www/vhosts/example.com && zip -rq /var/www/vhosts/example.com/private/httpdocs.zip httpdocs
caution

Recursively delete all files with a given name

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

Rename a file or directory

$mv -i -- /var/www/vhosts/example.com/httpdocs/index.html /var/www/vhosts/example.com/httpdocs/index.html.old
caution

Rename many files at once

$rename -n 's/\.jpeg$/.jpg/' *.jpeg
caution

Search for text in all files of a directory

$grep -rnI --include='*.php' 'base64_decode' /var/www/vhosts/example.com/httpdocs
harmless

Securely overwrite and delete a file

$shred -u -z -n 3 -- /root/old-dump.sql
destructive

Show all timestamps and permissions of a file

$stat /var/www/vhosts/example.com/httpdocs/wp-config.php
harmless

Show free disk space on all filesystems

$df -hT -x tmpfs -x devtmpfs -x squashfs
harmless

Show mounted filesystems with mount options

$findmnt -lo TARGET,SOURCE,FSTYPE,OPTIONS -t ext4,xfs,btrfs,vfat,nfs,nfs4,cifs
harmless

Show the size of all subdirectories

$du -xh -d 1 /var/www/vhosts 2>/dev/null | sort -rh | head -20
harmless

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.