Sie sind auf Seite 1von 2

Get the most from the du and df commands

While Linux has a number of very nice GUIs, using the command-line
interface can be faster and produce more information than GUI tools can,
especially when it comes to reporting and viewing disk usage.
The df tool simply reports the amount of free space on each partition — how
large they are, etc. It also provides information on non-local filesystems
(such as mounted NFS or Samba shares). In its most basic form, df provides
the following:
$ df
Filesystem 1K-blocks Used Available Use% Mounted
on
/dev/md2 4881472 793508 4087964 17% /

However, you can add options to df to show the filesystem type and show
the sizes in an easier to understand format:
$ df -h -T
Filesystem Type Size Used Avail Use% Mounted on
/dev/md2 xfs 4.7G 775M 3.9G 17% /

df can also list remotely mounted filesystems:


df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/md2 xfs 4.7G 786M 3.9G 17% /
/dev/md0 ext2 145M 7.2M 130M 6% /boot
atlas:/mnt/BIG nfs 465G 306G 160G 66%
/.automount/atlas/root/mnt/BIG
//surtr/Files
smbfs 254G 140G 115G 55% /mnt/Files

This shows the NFS mount /mnt/BIG from the system atlas is automounted,
and shows that the Samba share Files from the system surtr is mounted as
well.
While df provides an overview of entire partitions, the du tool will
summarize the size of a given directory, broken down by subdirectories:
$ du svn/ports
...
32 svn/ports/vnstat/.svn
48 svn/ports/vnstat
6248 svn/ports

Of course, to summarize the directory and all subdirectories and display size
values in a human-readable format, use:
$ du -sh svn/ports
6.2M svn/ports

Finally, to get a list of all the mounted filesystems on the system, use the
mount command. It will not only show the mounted filesystems, but the
associated mount options with each and those special filesystems that df
does not show:
# mount
/dev/md2 on / type xfs (rw)
none on /proc type proc (rw)
none on /proc/bus/usb type usbfs (rw)
none on /sys type sysfs (rw)
/dev/md0 on /boot type ext2 (rw,nosuid,nodev,noatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
build:(pid2286,port1022) on /net type nfs
(intr,rw,port=1022,toplvl,map=/etc/amd.net,noac)
atlas:/mnt/BIG on /.automount/atlas/root/mnt/BIG type nfs
(nosuid,nodev,rsize=32768,wsize=32768,intr,noatime,vers=3,proto=t
cp)
//surtr/Files on /mnt/Files type smbfs (0)

Delivered each Tuesday, TechRepublic’s free Linux NetNote provides tips,


articles, and other resources to help you hone your Linux skills.
Automatically sign up today!

Das könnte Ihnen auch gefallen