Sunday, November 22, 2026
TR
Linux

How to Find Which Folders and Files Take Up the Most Space on Linux

How to Find Which Folders and Files Take Up the Most Space on Linux

Organizing your file system can be one of the most tedious activities, but it is also vital when storage space is limited. In this article, we will simplify the process of identifying what is taking up disk space and help you keep your system as compact as possible.

List the largest directories

Most user-related files are stored in the home directory. To examine space usage in your home directory, use the following command:

du -h ~/ | sort -rh | head -n 10

du -h ~/: Calculates and displays the disk usage of all files and directories in your home directory in a human-readable format. If you want to check the size of a different directory, replace  ~/ with the path of that directory.

sort -rh : Takes the output of the du command and sorts it by size in descending order, taking the human-readable format into account.

head -n 10 : Takes the sorted output and displays only the first 10 lines, which correspond to the 10 largest directories in your home directory.

84K     /root/
20K     /root/snap
16K     /root/snap/lxd
12K     /root/var
12K     /root/.local
8.0K    /root/var/nfs
8.0K    /root/nfs
8.0K    /root/.ssh
8.0K    /root/.local/share

List the largest files in a directory

Identifying large files can be critical for freeing up a significant amount of disk space. The find command helps with this:

find ~/ -type f -exec du -h {} + | sort -rh | head -n 10

The new element here is the find command, which is used to search for files and directories in a given location. The options used in this section mean the following:

~/ : Specifies the starting directory of the search, which is your home directory.

-type f : Indicates that you are searching for files.

-exec du -h {} + : This part of the command runs the du -h command we explained above on every file that is found.

{} : This is a placeholder that represents each file found by the find command.

+ : This indicates that multiple file names can be passed to a single invocation of du.

4.0K    /root/.ssh/known_hosts
4.0K    /root/.profile
4.0K    /root/.bashrc
4.0K    /root/.bash_history
0       /root/sshfs/file
0       /root/file

💡It is also worth noting that some system directories can take up unexpected amounts of space. Use the du command 

to check the /var directory (logs and data), 

/tmp (temporary files) and 

/usr (installed software). 

Kerim Koç

Systems and infrastructure engineer. I write about Linux, open source, high availability and security.