#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
Analyze disk usage interactively with ncdu
$ncdu -x /var
Clean up unused Docker data
#docker system prune
Delete a scheduled WP-Cron event
$wp cron event delete old_plugin_daily_event --path=/var/www/vhosts/example.com/httpdocs
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
Delete downloaded package files from the apt cache
#du -sh /var/cache/apt/archives && apt clean
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
Delete local branches that are already merged
$git branch --merged main | grep -vE '^[*+]|^\s*(main|main|master|develop)$' | xargs -r git branch -d
Find directories with the most files
$du --inodes -x -d 1 /var/www/vhosts 2>/dev/null | sort -rn | head -20
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 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 without a valid owner
#find /var/www -xdev \( -nouser -o -nogroup \) -ls 2>/dev/null
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
List unused Docker volumes
#docker volume ls --filter dangling=true
Remove all unused Docker data including volumes
#docker system prune -a --volumes
Remove dangling Docker images
#docker image prune
Remove unused dependencies (apt autoremove)
#apt autoremove
Show Docker disk usage by images, containers and volumes
#docker system df -v
Show the size of all subdirectories
$du -xh -d 1 /var/www/vhosts 2>/dev/null | sort -rh | head -20
Shrink the systemd journal to a maximum size
#journalctl --vacuum-size=500M