How to Find out The Biggest Files & Directory on Linux

Windows Articles

How to install NetBeans on Windows 10

Hi! Today we're going to talk a little about Netbeans. This is an integrated development environment that allows programming in various languages....

How to install Atom Text Editor on Ubuntu 20.04?

It is often said that the process of software development is complex. And this is true, therefore it is required to use...

How to install Brackets in Windows 10 plus extensions

Hello! Brackets is an open-source code editor designed by Adobe for web developers. Additionally, it has a very simple and modern interface...

How to install Docker on OpenSUSE 15.2 / 15.1?

Docker is a fairly popular technology in today’s sysadmin. It is logical to think because it means a complete change in the...

How to analyze the network with IP Tools for Android

Hi! If you want to analyze and adjust the network almost professionally, then this post is for you. Indeed, IP Tools is...
Mel Khamlichi
Mel Khamlichihttp://www.osradar.com
Founder of Osradar, from Amsterdam Netherlands

For every Linux system admin, storage is a big issue. It’s especially true when you’re running a server machine where storage can become a big factor. It’s necessary to manage the directories so that enough storage space is available whenever needed. Everyday users can also easily manage their directory for ensuring the best performance and available disk space. Let’s take a look how to find out the largest directories and files under Linux.

The command tool

We’ll be using 2 tools today – “du” and “find”. “du” will show you the biggest directories under your system whereas “find” will show the largest files available on the disk.

Finding the largest directory

At first, let’s start with directory. Run this command for finding out the largest directory under “/home” partition.

du -a /home | sort -n -r | head -n 10

Let’s explain the details of the command:

  • du – Estimates the space usage of directory.
  • a – Display all the files & folders
  • sort – Sort text file lines
  • -n – Compare according to the numeric value of string
  • -r – Reverse the comparison(s) result
  • head – Output the first file part
  • -n (under “head” part) – Print N number of lines on the screen.

For searching and finding out the largest directory in the entire, run this command:

du -a | sort -n -r | head -n 5

The size of the files/folders will be shown in bytes. If you want human readable form like KB, MB or GB etc. then run this command line:

du -hs * | sort -rh | head -10

Here, “-h” argument will tell to show human readable form. You can also add the argument in the previous commands.

Finding out the top file sizes

If you’re interested only the top file sizes of your system, then use this command:

find -type f -exec du -Sh {} + | sort -rh | head -n 5

If you’re in need of searching the largest files in a specific directory, then follow this structure:

find ~/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5

OR

find ~/Downloads/ -type f -printf "%s %p\n" | sort -rn | head -n 5

Voila! The largest file(s)/directory(s) are discovered! Make changes accordingly to suit your needs. If your system is clogged with piles of images or small files, consider compressing them into a single archive.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install NetBeans on Windows 10

Hi! Today we're going to talk a little about Netbeans. This is an integrated development environment that allows programming in various languages....

How to install Atom Text Editor on Ubuntu 20.04?

It is often said that the process of software development is complex. And this is true, therefore it is required to use...

How to install Brackets in Windows 10 plus extensions

Hello! Brackets is an open-source code editor designed by Adobe for web developers. Additionally, it has a very simple and modern interface...

How to install Docker on OpenSUSE 15.2 / 15.1?

Docker is a fairly popular technology in today’s sysadmin. It is logical to think because it means a complete change in the...

How to analyze the network with IP Tools for Android

Hi! If you want to analyze and adjust the network almost professionally, then this post is for you. Indeed, IP Tools is...