Sunday, January 3, 2010

The Unix df Command Under Linux

One of the commands I use the
most frequently under Linux is
the df command.

df stands for disk
free
. Basically, the
df command tells you
how much of your hard drive
has been used up.

This is very useful.

With df, you know whether
you have 50 percent of your hard
drive left for additional storage
or only 10 percent left.

Big difference.

Again, df means disk
free
. This is exactly what
df tells you. How much
of the hard drive is free for
you to add other things to it.

Here's how to use the df
command:


df

Simple, isn't it?

Here some input and output:

$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda3            123079960  83666812  33161052  72% /
tmpfs                   518136         0    518136   0% /lib/init/rw
udev                     10240       672      9568   7% /dev
tmpfs                   518136         0    518136   0% /dev/shm
$

The final dollar sign is my prompt
coming back.

You can make the df command
quite a bit more useful by adding
the -h option to it.

The -h means human
readable
. With -h, df
reports usage in megabytes
and gigabytes, and other units of
measure that are easy to digest.

Here's what df looks like with
-h present:

df -h

Here's a sample input and output for
df with the -h present:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3             118G   80G   32G  72% /
tmpfs                 506M     0  506M   0% /lib/init/rw
udev                   10M  672K  9.4M   7% /dev
tmpfs                 506M     0  506M   0% /dev/shm
$

Again, the final dollar sign
is my prompt coming back.
The initial dollar sign is the
prompt as it appears before
I've typed anything.

Note that df gives me 6
columns of information.

Perhaps the most important column
is the second column. This is the
size column.

This tells me, in megabytes or
gigabytes, how much space I have
left on my hard drive.

In my case, I have used up 80
gigabytes of storage and have
only 32 gigabytes left.

To see this, look at line one and
ignore the other lines.

Like many Unix commands, df
gives you more information that you
want initially.

Likely as not, the information you
will want from df is all on
the first line. At least, that's
true in this case.

Ed Abbott

No comments:

Post a Comment