free disk space
Find what fills a disk, then clear what is safe to clear: old package files, logs, caches.
danger Steps marked in red delete, overwrite or stop something. Read each one before you run it.
Steps
-
df -hsee how full each disk is, and which one is short of space
-
du -xh -d 1 / 2>/dev/null | sort -hthe biggest folders at the top of that disk, biggest last
-
ncdu -x /walk through the folders by size and delete from there, if ncdu is installed
-
sudo journalctl --vacuum-size=200Mshrink the system's logs to 200 MB
-
sudo apt cleanremove the downloaded package files (Debian, Ubuntu)
-
sudo apt autoremoveremove the packages nothing needs any more (Debian, Ubuntu)
-
rm -rf ~/.cache/thumbnailsdanger delete the cached thumbnails, made again when needed
Notes
- Fedora and RHEL:
sudo dnf clean allandsudo dnf autoremove. Arch:sudo pacman -Sc. -xkeepsduandncduon that one disk, so other disks and network folders are not counted.- macOS: the same
df -handdu -xh -d 1 /; Homebrew's downloads go withbrew cleanup.
Commands used
dfduncdujournalctl
Each has a page in lore: lore df opens it.
Related recipes
- create a large fileMake a file of a given size, for testing disks, uploads or swap.
- disk full but df says there is room"No space left on device" with free gigabytes: the disk is out of inodes, the slots for files. Find the folder with too many small files.
- find big filesFind the files that take the most room, on a whole disk or in a folder.
- see the size of files and foldersHow much room each file and folder takes, here or anywhere, biggest last.