Ciberjohn's

Using the du command to find folder sizes

linux girl

The following command would display all the files and folder as well as their size as a list:

du -sm *

however this is not an ordered list . To order the list we would need to pipe 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. 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 .


  1. ciberjohn posted this
To Tumblr, Love PixelUnion

We're updating Fluid!

Soon, we'll be updating the look and feel of this theme. Read about the changes here. You can easily turn off this notification in the theme customization panel.

Close