How to Discover Disk Usage in Linux


Like it or not, Linux has become the dominant operating system of every day life.  Nearly every phone, tablet, media streamer, even smart TVs and gaming consoles are based on some flavor on Linux.

To stay competitive, even “classic” keyboard-and-mouse desktop computer systems are adapting to the new mobile trend (e.g. Windows 8 and Android).  While Linux has a reputation of being hard to use, modern versions up the usability ante beyond the most popular devices.  Ubuntu in particular has Windows beat when it comes to usability, power, and flexibility (especially after tweaking with its built-in Unity Tweak Tool), but that is a topic for another article.

One common task that users need to do is find out how much stuff is in their directories.  You can still do some very powerful things with traditional text commands, but there are some even more powerful GUI tools available.

Many ways to get disk usage in Linux

Command-line tools

If you are using a Linux terminal (such as a server) and need to see the disk usage of a particular directory, you can use a few different commands, and they each have different output. use the following command:

du -h <yourdirectory>

Which should output a list of sub-directories and how much each one uses.

There are a few optional arguments. The following code summarizes the output your home folder and sorts numerically:

du -sh ~/* | sort -n

Using the “df” command will show you the amount of space left by volume.

These commands are easier to remember when you realize that du means “disk usage” and df means “disk free”. The “s” argument means to summarize, and the “h” argument means to output in a “human-readable” format (round up to the nearest unit)

There are a few other command-line options such as “pydf“, “discus“, “df” and “di“, but they may not come pre-installed on your system.  For more details you can go to the askubuntu forums.

GUI options

Modern versions of Linux have some pretty neat GUI options to display your file usage.  One that should be on every distribution is the System Monitor.  If you open this up and then click the “File Systems” tab then you should be a basic table with some basic disc information.

One of the fancier tools that comes with Ubuntu is the Disk Usage Analyzer, which is similar to KDirStat and WinDirStat.  The Opening Disk Usage Analyzer brings up a basic view, but when you click the drive icon at the top then the tool traverses your drive and builds up an expandable list with detailed information per directory, along with handy charts and graphs.  This is one of the best tools available, and it comes pre-installed with Ubuntu.

Disk Usage Analyzer basic and detailed modes

If you have a different Linux distribution that doesn’t have this tool, then you may want to download KDirStat, TreeSize, or xdiskusage.

Left: Disk Usage Analyzer easy to find on Ubuntu. Right: KDirStat

More people will begin to adopt Linux as their everyday operating system when they become aware of these great easy-to-use utilities that rival canned Windows programs.

Alan is a web architect, stand-up comedian, and your friendly neighborhood Grammar Nazi. You can stalk him on the Interwebs via Google+, Facebook and follow his ass on Twitter @ocmodshop.