How to Find The Biggest Folders In Linux

Written by: Bagus Facsi Aginsa
Published at: 31 Oct 2023

If you are looking for a folder that takes up the most space in your Linux, you can use du command to find them. Let’s try some use cases using du in Linux.

Find The Biggest Folders

To find the biggest folders in your Linux system, you can use this command:

du -h / | sort -hr | head -n 20

This command will find the 20 biggest folders on your system and sort them from the biggest to the smallest. You will see a response like this when you run those commands:

CLI response to du -h / command

If you see some errors like those first four lines, you can ignore them.

Find The Biggest Folders in Specific Location

To find the biggest folders in a specific location, you can change the / to the location you desire. Let’s see some examples. We will run this command to find the biggest folder in /var location:

du -h /var | sort -hr | head -n 20

This is the capture result:

CLI response to du -h /var command

Notice that the result only shows folder size inside /var as we expected.

That’s it! Now you can remove them using this command below

rm -rf <folder name>