How to Find Large Files on Ubuntu (to Free Up Space)
Running low on storage? Ubuntu’s terminal has a quick command to help you hunt down those space-hogging files. Instead of manually digging through folders, you can use a simple command to locate large files and decide what can go.
Just open the terminal and type: sudo find / -type f -size +100M
. Here, the +100M
part tells Ubuntu to find files larger than 100 MB, but you can adjust this to any size that works for you. Starting from the root directory (/
) means it’ll look everywhere, but if you want to search just your home folder, use find ~/ -type f -size +100M
.
This command quickly lists all files meeting your size criteria, making it easy to decide what can go. A quick scan might reveal old downloads, cached videos, or backups you no longer need. So, give it a go, and make some space for the important stuff!
How to Find and Sort Large Files on a Specific Drive in Ubuntu
To scan a specific drive and find large files, open your terminal and use the following command:sudo find /path/to/drive -type f -size +100M -exec ls -lh {} + | sort -k 5 -rh
Here’s what’s happening:
Replace
/path/to/drive
with the actual path to your drive (e.g.,/media/username/drivename
).The
-type f
flag searches only for files (ignoring directories).The
-size +100M
option locates files over 100 MB in size (you can change this to any size that suits).Using
-exec ls -lh {}
gives you detailed file info, and thensort -k 5 -rh
sorts them by size, showing the largest files first.
This command will quickly give you a sorted list of big files on your drive, so you can zero in on what’s taking up the most space. Then simply use a file browser on Ubuntu to delete those files.
To delete a file via Terminal, just navigate to the specific directory, and use this command: rm /path/to/your/file
How do you find your Ubuntu username?
Simply go into Terminal, and search whoami
Now use this command to do the search and sort:sudo find /home/yourusername -type f -size +100M -exec ls -lh {} + | sort -k 5 -rh
Hope all this helps!