Subscribe to How-To Geek

Get the Top 10 Files or Directories on Ubuntu Linux

Ubuntu Linux has a rich set of commands for manipulating and accessing files. The du utility gives information on disk usage, and the sort utility can sort the results. Finally, we can run those results through the head command, which gives you the top 10 lines outputted through any other command. We’ll chain the commands together to get the output that we want.

First we’ll use the du -sm command to give the results in MB:

$ du -sm *
1 wp-config-sample.php
1 wp-config.php
14 wp-content
1 wp-feed.php
—- trimmed —

Now we can see that the results aren’t sorted, so we’ll sort them by the sort -nr command, which sorts by numerical value in reverse. Finally, we’ll run the results through head -10 to get the top 10 results:

This is the command we are going to run:

du -sm * | sort -nr | head -10

Here’s an example of the output:

$ du -sm * | sort -nr | head -10
14 wp-content
2 wp-includes
1 xmlrpc.php
1 xml.php
1 x.php
1 wp-trackback.php
1 wp-settings.php
1 wp-rss2.php
1 wp-rss.php
1 wp-register.php

Useful stuff.

| More
This article was originally written on 11/26/06 Tagged with: Shell Scripts, Ubuntu, Ubuntu Tips & Tweaks

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:

Comments (3)

  1. morganusvitus

    The site looks great ! Thanks for all your help ( past, present and future !)

  2. alex

    hi nice site.

  3. anatol

    Nise site!


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Our Friends
Getting Started


About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
mDNSResponder.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
conhost.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.