|
|
May
12, 2003
- Tracking
Down Disk Space "Hogs" - The du
Command - Part I
|
|
To
be successful at UNIX system
administration, there are a number of
inherent tasks that MUST be performed by
the system administrator. One of the
primary inherent tasks is monitoring and
managing disk space usage.
The system administrator needs to be
proactive in regards to this
responsibility (e.g. by setting up
automated monitoring and notification
programs), or may experience one or more
of the following if a key filesystem
becomes full:
|
· system
slow-down
· users unable to log in
· a system crash
|
Even
with an automated monitoring/notification
solution in place, there may be times when
the system administrator will have to be
reactive in identifying disk space
"hogs." One of the most
common tools for handling this is the du
("disk usage") command.
The syntax for du is:
|
du
[OPTION...] [DIRECTORY...]
|
The
command will report the amount of disk
space used by all of the files and
subdirectories located beneath the
directory specified with the DIRECTORY
command argument. The following
example shows the du output for one particular system's /home directory:
|
# 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
|
Notice that
the results are listed on a
per-subdirectory basis. Since there
are only two non-system users on this
server, it is easy to identify that wilbur
is the largest consumer of disk space
within /home. It can also be seen
that files in wilbur's "tmp"
subdirectory are consuming the largest
amount of space within /home/wilbur.
The total amount of space used by files
and directories underneath /home in this
example is 1,276 blocks. The size of
a block is typically 512 or 1,024 bytes,
but each system's documentation should be
consulted to determine the default size it
uses.
Visually identifying heavy disk space
users works fine if there are only a
handful of users on a system, but how
would one quickly accomplish this same
task on a system with hundreds or
thousands of users?
Stop by this page next Monday to find out,
or use the box in the upper-right corner
of this page to receive LiveFire Labs'
Tip, Trick, or Shell Script of the Week
via email.
|
|
|
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
|
|
|
|
 |
 |
| |
Receive
the UNIX Tip, Trick, or Shell Script of the
Week by Email
|
|
|
|