Which Directory Uses The Most Disk Space In Linux

Updated: Feb 8

We can use the following commands to find the largest files and directories in #Linux.

Find Largest Files and Directories under a specific directory and subdirectory in Linux

# du -ah /home | sort -n -r | head -n 5

Find Largest Files and Directories under the current working directory and subdirectory.

# du -ah | sort -n -r | head -n 5

Find Largest Directories or Files in the current working directory

# du -sh * | sort -rh | head -5

Find Largest Directories or Files in / directory

# du -ahx / | sort -rh | head -5

We use the following commands in our examples.

  • #du command : It estimates file space usage

  • sort command : Sort lines of text files or given input data

  • head command : Output the first part of files i.e. to display first 10 largest file

We use the following options in our examples.

  • #du command -h option : display file sizes in human-readable format, in Kilobytes, Megabytes and Gigabytes.

  • du command -s option : Show total for each argument.

  • du command -x option : Skip directories. (if on different file systems)

  • sort command -r option : Reverse the result of comparisons.

  • sort command -h option : Compare the numbers.

  • head command -10 OR -n 10 option : Displays the first 10 lines of the output.


Join our mail group. Get a free Linux account on Cloud.

Never miss a post!

Want a free Linux account?  This account can be used to login to our cloud server and practice Linux commands.


✔ Linux Commands   ✔ Linux Skills    ✔ LinuxPerformance   ✔ Linux Interview

Some articles are from the public internet. If you find your article misused or undesired here and you don't want us to display it, please let us know and we'll remove it immediately.