LiveFire Labs - Online UNIX Training - Company Logo


Online UNIX Training with Hands-on Internet Lab


"Eliminate the expense and inconvenience of classroom training without eliminating the classroom experience."

 


Home
Internet Lab
Console Access
Sample Course

Student Login


LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week - View


Questions? Call
1.888.843.1637 or send us email

May 19, 2003 - Tracking Down Disk Space "Hogs" - The du Command - Part II

In last week's tip, the du (disk usage) command was used to quickly identify wilbur as the largest consumer of disk space within /home by glancing at the command's output:

# du /home
4          /home/jdoe/tmp/docs1
8          /home/jdoe/tmp
4          /home/jdoe/testdir1
4          /home/jdoe/testdir2
4          /home/jdoe/testdir3
4          /home/jdoe/docs
128      /home/jdoe
4          /home/wilbur/tmp/docs1
1036     /home/wilbur/tmp
4          /home/wilbur/testdir1
4          /home/wilbur/testdir2
4          /home/wilbur/testdir3
4          /home/wilbur/docs
1144     /home/wilbur
1276     /home

We left off by stating that this works fine when there are only a handful of users on a system, but how could you quickly identify the disk space "hogs" on a system with hundreds or thousands of users?

This can easily be accomplished by piping the output from the du command to the sort command:

# du /home | sort -nr
1276     /home
1144     /home/wilbur
1036     /home/wilbur/tmp
128       /home/jdoe
8          /home/jdoe/tmp
4          /home/wilbur/tmp/docs1
4          /home/wilbur/testdir3
4          /home/wilbur/testdir2
4          /home/wilbur/testdir1
4          /home/wilbur/docs
4          /home/jdoe/tmp/docs1
4          /home/jdoe/testdir3
4          /home/jdoe/testdir2
4          /home/jdoe/testdir1
4          /home/jdoe/docs

If you are not intimately familiar with the sort command, the -n option sorts the data by numeric field first, and the -r option will reverse the results.  If the number of users on your system requires you to sort the results, you will most likely also need to pipe the sorted results to the more command:

# du /home | sort -nr | more

In doing so, you will be able to view one screen of results at a time.

There are many options available for monitoring and managing disk space on a UNIX system, but the du command is one that should always be available for quickly identifying a system's heavy disk space consumers.


Learn more...
  

If you are new to the UNIX or Linux operating system and would like to learn more about other frequently-used operating system commands, you may want to consider registering for LiveFire Labs' UNIX and Linux Operating System Fundamentals online training course.

If you already have a solid grasp of the fundamentals but would like to learn more about UNIX system administration, taking our UNIX System Administration course will be beneficial to you.

Our innovative hands-on training model allows you to learn UNIX by completing hands-on exercises on real servers in our Internet Lab.


More Tips...

· 
Popular UNIX Tips from the Past

spacer Box Border
 

Receive the UNIX Tip, Trick, or Shell Script of the Week by Email


First Name:


Email Address:






   1.888.843.1637

Home - Contact us - Company info - Privacy Statement   

 
©2002-2003 LiveFire Labs.  All rights reserved.
Linux® is a registered trademark of Linus Torvalds, author and developer of this public domain operating system.
UNIX® is a registered trademark of The Open Group in the United States and other countries.