Skip to main content

Displaying sorted list(size wise) of Files/Folder on Linux

Even though i have a 120 GB HDD on my laptop and have dedicated a significant portion of hard disk space to Ubuntu still somehow every three or four months i run out of disk space . Also i am particularly bad at organizing stuff and well files are cluttered over my entire file system this makes tracking large files i don't need very difficult . Lots of application create a number of temporary files and these files also take significant amount of disk space and could be hard to track down if they are not created in /tmp .

The command I am discussing below helps you solve precisely this problem by giving you an ordered list (ordered in terms of size) of files and folders taking up space in your computer thus helping you find files/folder which are taking up significant amount of space :

du -sm *

Above command would display all the files and folder as well as their size as a list, however this is not a ordered list . To order the list we would need to pipe (that is send output of this command to another ) the output of the "du" command to "sort" command giving out list of files and folders sorted in ascending order according to the size.
du -sm * | sort -nr

Still there is a problem this is an entire list of files and folder in your file system , so if you have number of files and folders it will take number of screens to display . A better way would be to pipe the output of above command to "head" command to display only specified number of lines of output generated by "du -sm * | sort -nr " command .

du -sm *| sort -nr | head -15
Now the above command would display the top 15 files and folder according to their size .

Article Written by : Ambuj Varshney (
For Desktop on Linux Blog ,
(C) 2008 , Ambuj Varshney


  1. It's probably worth mentioning that the output is in MB, not bytes.

    Initially my first thought on reading this was why not use "-h" and get it in, M, K, G depending, but when I tried it I realised that then the largest number, irrespective of unit, comes first so you could have: 688M, 500K, 4G in that order. Obviously when the list is long then you will miss many of the largest files...

    Thanks for the tip.

  2. Anonymous4:33 PM

    A better solution, in my opinion, would be to use the Disk Usage Analyser application in Ubuntu to drill down graphically. The only downside is that it takes a lot of time to start up.

  3. Anonymous5:38 PM

    I'm not sure about the way you have this command setup. From man du you can see that the -s flag just spits out a summary of everything without listing the files. If you just take out -s, this command works nicely.


Post a Comment

Popular posts from this blog

13 Things to do immediately after installing Ubuntu

In this article i describe some of the things to do immediately after installing ubuntu on your machine . Since most of the people reading this would be shifting from Windows to Linux with a system dual booting so i would focus more on making transition easy from Windows to Linux.

Creating Your ultimate Ubuntu 7.10 Desktop

Ubuntu 7.10 Codenamed Gusty Gibbon was released few weeks back with much fanfare ,now Ubuntu for past couple of years has been one of the most popular Desktop Linux distributions . Ubuntu 7.10 includes a number of features , applets and Wizards to simplify desktop Linux experience however because of many licensing restrictions it does not include out of the box support for popular audio/video codecs and many commercial but good applications . Also because of the limitation of trying to accommodate all kind of applications on single CD Ubuntu comes with a limited set of applications .

Now , i often have arguments with my friends who are new to computers that windows is…

Over 16 Small Games For Ubuntu Linux

Over 16 Small Games For Ubuntu Linux

Ubuntu Linux is one of the most popular Linux distribution , it is especially popular among Linux newbies and windows refuges . Now Ubuntu Linux does come with a descent set of applications , still there is a scope for including some more quality applications and especially games . Now in this tutorial i will show you how to install a large number of small , easy and less resource hungry games on Ubuntu Linux with screen-shots of games .

1. Rocks 'n' Diamonds

Rocks 'n' Diamonds is a Boulderd*sh game for X11 with more than just the falling rocks and diamonds of its namesake. The object is still to collect all the diamonds (and emeralds), then get to the exit before time runs out. But your character must make use of bombs, spaceships, and many other elements in order to fill his quota of jewels.

Installation : -

Type the following command in the terminal window


35 Cool Applications to install on Ubuntu 7.04

35 Cool Applications to install on Ubuntu 7.04
(Important : This Tutorial is For Ubuntu 7.04 To Read the Updated Article for Ubuntu 7.10 Read the Following Articles :

Cool Desktop Linux Applications(Part 1) : Internet and networking applications

Cool Desktop Applications(Part 2) : 25 Small and Simple Games for your Linux/Ubuntu Desktop

Ubuntu 7.04 is undoubtedly one of the most popular Linux distribution especially for Linux newbies , now overall it is extremely usable and good but a very limited number of applications are by default shipped with Ubuntu 7.04 . Now here in this article we look at a number of really good applications that are not shipped by default with Ubuntu as well as instructions on installing them : -

Installing/Enabling additional Repositories
Now many applications need additional repositories to be installed or some to be enabled in Synaptic package manager so before trying out steps given below ensure that repositories in order.

launch Synaptic Package Manager (Syst…