How to Find Large Files and Directories
When your disk space is running low, you need to find out what's taking up all the space.
Finding the Largest Directories
The `du` (disk usage) command is perfect for this. This command will show the top 10 largest directories in the current location:
du -ah . | sort -rh | head -n 10
CopyFinding Individual Large Files
The `find` command can search for files larger than a specific size. For example, to find files larger than 500MB in the `/` directory:
sudo find / -type f -size +500M -exec ls -lh {} \;
CopyInteractive Disk Usage Analyzer
For an easy-to-use interactive view, install and run `ncdu`:
# Install ncdu
sudo apt install ncdu -y # Ubuntu/Debian
sudo dnf install ncdu -y # AlmaLinux/CentOS
# Run it on a directory
ncdu /
Copy