How to Find out The Biggest Files & Directory on Linux

Windows Articles

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...

Install Matomo on Ubuntu 20.04

Hello, friends. In this post, you will learn how to install Matomo on Ubuntu 20.04. It's quite useful to measure the traffic to our...

How to change DNS in Windows 10

Hi! Today we will talk a bit about networks. In fact, we will touch on a topic related to connectivity. Specifically we will see...

The new Windows 10 file explorer will arrive with 21H2 update.

Hello! Microsoft does not stop working (except at Christmas) to continue polishing to Windows 10. In fact, users are gradually receiving the 20H2 update....

How to create an FTP server in Android

Hello! How are you? Currently sharing files from your PC to Android can be more comfortable and easy, without the need to use a...
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

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...

Install Matomo on Ubuntu 20.04

Hello, friends. In this post, you will learn how to install Matomo on Ubuntu 20.04. It's quite useful to measure the traffic to our...

How to change DNS in Windows 10

Hi! Today we will talk a bit about networks. In fact, we will touch on a topic related to connectivity. Specifically we will see...

The new Windows 10 file explorer will arrive with 21H2 update.

Hello! Microsoft does not stop working (except at Christmas) to continue polishing to Windows 10. In fact, users are gradually receiving the 20H2 update....

How to create an FTP server in Android

Hello! How are you? Currently sharing files from your PC to Android can be more comfortable and easy, without the need to use a...
x