[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14. Disk usage

No disk can hold an infinite amount of data. These commands report on how much disk storage is in use or available. (This has nothing much to do with how much main memory, i.e., RAM, a program is using when it runs; for that, you want ps or pstat or swap or some such command.)

14.1 df: Report filesystem disk space usage  Report filesystem disk space usage.
14.2 du: Estimate file space usage  Estimate file space usage.
14.3 stat: Report file or filesystem status  Report file or filesystem status.
14.4 sync: Synchronize data on disk with memory  Synchronize memory and disk.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.1 df: Report filesystem disk space usage

df reports the amount of disk space used and available on filesystems. Synopsis:

 
df [option]... [file]...

With no arguments, df reports the space used and available on all currently mounted filesystems (of all types). Otherwise, df reports on the filesystem containing each argument file.

Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see section 2.2 Block size). Non-integer quantities are rounded up to the next higher unit.

If an argument file is a disk device file containing a mounted filesystem, df shows the space available on that filesystem rather than on the filesystem containing the device node (i.e., the root filesystem). GNU df does not attempt to determine the disk usage on unmounted filesystems, because on most kinds of systems doing so requires extremely nonportable intimate knowledge of filesystem structures.

The program accepts the following options. Also see 2. Common options.

`-a'
`--all'
Include in the listing filesystems that have a size of 0 blocks, which are omitted by default. Such filesystems are typically special-purpose pseudo-filesystems, such as automounter entries. Also, filesystems of type "ignore" or "auto", supported by some operating systems, are only included if this option is specified.

`-B size'
`--block-size=size'
Scale sizes by size before printing them (see section 2.2 Block size). For example, `-BG' prints sizes in units of 1,073,741,824 bytes.

`-h'
`--human-readable'
Append a size letter to each size, such as `M' for mebibytes. Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes. Use the `-H' or `--si' option if you prefer powers of 1000.

`-H'
`--si'
Append an SI-style abbreviation to each size, such as `MB' for megabytes. Powers of 1000 are used, not 1024; `MB' stands for 1,000,000 bytes. Use the `-h' or `--human-readable' option if you prefer powers of 1024.

`-i'
`--inodes'
List inode usage information instead of block usage. An inode (short for index node) contains information about a file such as its owner, permissions, timestamps, and location on the disk.

`-k'
Print sizes in 1024-byte blocks, overriding the default block size (see section 2.2 Block size). This option is equivalent to `--block-size=1K'.

`-l'
`--local'
Limit the listing to local filesystems. By default, remote filesystems are also listed.

`--no-sync'
Do not invoke the sync system call before getting any usage data. This may make df run significantly faster on systems with many disks, but on some systems (notably SunOS) the results may be slightly out of date. This is the default.

`-P'
`--portability'
Use the POSIX output format. This is like the default format except for the following:

  1. The information about each filesystem is always printed on exactly one line; a mount device is never put on a line by itself. This means that if the mount device name is more than 20 characters long (e.g., for some network mounts), the columns are misaligned.

  2. The labels in the header output line are changed to conform to POSIX.

`--sync'
Invoke the sync system call before getting any usage data. On some systems (notably SunOS), doing this yields more up to date results, but in general this option makes df much slower, especially when there are many or very busy filesystems.

`-t fstype'
`--type=fstype'
Limit the listing to filesystems of type fstype. Multiple filesystem types can be specified by giving multiple `-t' options. By default, nothing is omitted.

`-T'
`--print-type'
Print each filesystem's type. The types printed here are the same ones you can include or exclude with `-t' and `-x'. The particular types printed are whatever is supported by the system. Here are some of the common names (this list is certainly not exhaustive):

`nfs'
An NFS filesystem, i.e., one mounted over a network from another machine. This is the one type name which seems to be used uniformly by all systems.

`4.2, ufs, efs...'
A filesystem on a locally-mounted hard disk. (The system might even support more than one type here; Linux does.)

`hsfs, cdfs'
A filesystem on a CD-ROM drive. HP-UX uses `cdfs', most other systems use `hsfs' (`hs' for "High Sierra").

`pcfs'
An MS-DOS filesystem, usually on a diskette.

`-x fstype'
`--exclude-type=fstype'
Limit the listing to filesystems not of type fstype. Multiple filesystem types can be eliminated by giving multiple `-x' options. By default, no filesystem types are omitted.

`-v'
Ignored; for compatibility with System V versions of df.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.2 du: Estimate file space usage

du reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments). Synopsis:

 
du [option]... [file]...

With no arguments, du reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see section 2.2 Block size). Non-integer quantities are rounded up to the next higher unit.

The program accepts the following options. Also see 2. Common options.

`-a'
`--all'
Show counts for all files, not just directories.

`-b'
`--bytes'
Print sizes in bytes, overriding the default block size (see section 2.2 Block size).

`-B size'
`--block-size=size'
Scale sizes by size before printing them (see section 2.2 Block size). For example, `-BG' prints sizes in units of 1,073,741,824 bytes.

`-c'
`--total'
Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk usage of a given set of files or directories.

`-D'
`--dereference-args'
Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as `/usr/tmp', which are often symbolic links.

`-h'
`--human-readable'
Append a size letter to each size, such as `M' for mebibytes. Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes. Use the `-H' or `--si' option if you prefer powers of 1000.

`-H'
`--si'
Append an SI-style abbreviation to each size, such as `MB' for megabytes. Powers of 1000 are used, not 1024; `MB' stands for 1,000,000 bytes. Use the `-h' or `--human-readable' option if you prefer powers of 1024.

`-k'
Print sizes in 1024-byte blocks, overriding the default block size (see section 2.2 Block size). This option is equivalent to `--block-size=1K'.

`-l'
`--count-links'
Count the size of all files, even if they have appeared already (as a hard link).

`-L'
`--dereference'
Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link).

`--max-depth=DEPTH'
Show the total for each directory (and file if --all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so du --max-depth=0 is equivalent to du -s.

`-s'
`--summarize'
Display only a total for each argument.

`-S'
`--separate-dirs'
Report the size of each directory separately, not including the sizes of subdirectories.

`-x'
`--one-file-system'
Skip directories that are on different filesystems from the one that the argument being processed is on.

`--exclude=PATTERN'
When recursing, skip subdirectories or files matching PATTERN. For example, du --exclude='*.o' excludes files whose names end in `.o'.

`-X FILE'
`--exclude-from=FILE'
Like `--exclude', except take the patterns to exclude from FILE, one per line. If FILE is `-', take the patterns from standard input.

On BSD systems, du reports sizes that are half the correct values for files that are NFS-mounted from HP-UX systems. On HP-UX systems, it reports sizes that are twice the correct values for files that are NFS-mounted from BSD systems. This is due to a flaw in HP-UX; it also affects the HP-UX du program.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.3 stat: Report file or filesystem status

stat displays information about the specified file(s). Synopsis:

 
stat [option]... [file]...

With no option, stat reports all information about the given files. But it also can be used to report the information of the filesystems the given files are located on. If the files are links, stat can also give information about the files the links point to.

`-f'
`--filesystem'
Report information about the filesystems where the given files are located instead of information about the files themselves.

`-L'
`--dereference'
Change how stat treats symbolic links. With this option, stat acts on the file referenced by each symbolic link argument. Without it, stat acts on any symbolic link argument directly.

`-t'
`--terse'
Print the information in terse form, suitable for parsing by other programs.

`-c'
`--format'
Allow user to specify the output format.

Interpreted sequences for file stat are:

Interpreted sequences for filesystem stat are:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.4 sync: Synchronize data on disk with memory

sync writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; The sync program does nothing but exercise the sync system call.

The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes. This improves performance, but if the computer crashes, data may be lost or the filesystem corrupted as a result. sync ensures everything in memory is written to disk.

Any arguments are ignored, except for a lone `--help' or `--version' (see section 2. Common options).


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Jeff Bailey on December, 28 2002 using texi2html