↑ ↓ select, Enter open, Esc close

#cleanup

22 one-liners with this tag.

All one-liners tagged cleanup

Recursively delete all files with a given name

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

Analyze disk usage interactively with ncdu

$ncdu -x /var
harmlessFilesystem

Clean up unused Docker data

#docker system prune
cautionDocker

Delete a scheduled WP-Cron event

$wp cron event delete old_plugin_daily_event --path=/var/www/vhosts/example.com/httpdocs
cautionWP-CLI

Delete all post revisions

$wp post list --post_type=revision --format=ids --path=/var/www/vhosts/example.com/httpdocs | xargs -r wp post delete --force --path=/var/www/vhosts/example.com/httpdocs
destructiveWP-CLI

Delete downloaded package files from the apt cache

#du -sh /var/cache/apt/archives && apt clean
cautionDebian and APT

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

Delete local branches that are already merged

$git branch --merged main | grep -vE '^[*+]|^\s*(main|main|master|develop)$' | xargs -r git branch -d
cautionGit

Find directories with the most files

$du --inodes -x -d 1 /var/www/vhosts 2>/dev/null | sort -rn | head -20
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 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 without a valid owner

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

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

List unused Docker volumes

#docker volume ls --filter dangling=true
harmlessDocker

Remove all unused Docker data including volumes

#docker system prune -a --volumes
destructiveDocker

Remove dangling Docker images

#docker image prune
cautionDocker

Remove unused dependencies (apt autoremove)

#apt autoremove
cautionDebian and APT

Show Docker disk usage by images, containers and volumes

#docker system df -v
harmlessDocker

Show the size of all subdirectories

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

Shrink the systemd journal to a maximum size

#journalctl --vacuum-size=500M
destructivesystemd

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.