#disk-space
26 one-liners with this tag.
All one-liners tagged disk-space
Empty a file without deleting it
$truncate -s 0 -- /var/www/vhosts/example.com/logs/error_log
Analyze disk usage interactively with ncdu
$ncdu -x /var
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}'
Check inode usage of filesystems
$df -ih -x tmpfs -x devtmpfs -x squashfs
Clean up unused Docker data
#docker system prune
Delete downloaded package files from the apt cache
#du -sh /var/cache/apt/archives && apt clean
Disk usage of all webspaces under /var/www/vhosts
#du -sh /var/www/vhosts/*/ 2>/dev/null | sort -rh | head -20
Find deleted files still held open
#lsof -nP +L1
Find the 20 largest tables on the server
#mysql -e 'SELECT table_schema, table_name, ROUND((data_length + index_length) / 1024 / 1024, 1) AS mb, table_rows FROM information_schema.tables ORDER BY data_length + index_length DESC LIMIT 20;'
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 the largest files in the entire Git history
$git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '$1=="blob"' | sort -k3 -rn | head -n 20
Find the largest log files on the server
#du -ah /var/log 2>/dev/null | sort -rh | head -20
Force log rotation immediately
#logrotate -vf /etc/logrotate.d/nginx
List installed packages sorted by size
$dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rn | head -n 20
Mailbox disk usage per domain in Plesk
#du -sh /var/qmail/mailnames/*/ 2>/dev/null | sort -rh | head -20
Permanently limit the size of the systemd journal
#mkdir -p /etc/systemd/journald.conf.d && printf '[Journal]\nSystemMaxUse=500M\n' > /etc/systemd/journald.conf.d/size.conf && systemctl restart systemd-journald
Remove dangling Docker images
#docker image prune
Show details and disk usage of a Plesk subscription
#plesk bin subscription --info example.com
Show disk space used by the systemd journal
#journalctl --disk-usage
Show Docker disk usage by images, containers and volumes
#docker system df -v
Show free disk space on all filesystems
$df -hT -x tmpfs -x devtmpfs -x squashfs
Show the disk usage of Docker containers
#docker ps -a --size
Show the size of all databases in MB
#mysql -e 'SELECT table_schema AS db, ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS mb FROM information_schema.tables GROUP BY table_schema ORDER BY mb DESC;'
Show the size of all subdirectories
$du -xh -d 1 /var/www/vhosts 2>/dev/null | sort -rh | head -20
Show the size of WordPress database tables
$wp db size --tables --path=/var/www/vhosts/example.com/httpdocs
Shrink the systemd journal to a maximum size
#journalctl --vacuum-size=500M