To display the disk space usage for your drives in Linux, you are able to use the df command. By default, it will show the usage of all the mounted drives in 1k blocks. If the POSIXLY_CORRECT environment variable is set though, it will show in 512 byte blocks by default. Below shows the command run with no options.
[email protected]:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdc1 575758492 126365356 420575064 24% /
udev 1538192 12 1538180 1% /dev
tmpfs 619612 1088 618524 1% /run
none 5120 0 5120 0% /run/lock
none 1549020 144 1548876 1% /run/shm
I personally like to use the -h flag with it, which will show the space in human readable format, in KB and GB.
[email protected]:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdc1 550G 121G 402G 24% /
udev 1.5G 12K 1.5G 1% /dev
tmpfs 606M 1.1M 605M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.5G 144K 1.5G 1% /run/shm
The -a flag will show all of the file systems, including dummy file systems.
[email protected]:~$ df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdc1 575758492 126365360 420575060 24% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
none 0 0 0 - /sys/fs/fuse/connections
none 0 0 0 - /sys/kernel/debug
none 0 0 0 - /sys/kernel/security
udev 1538192 12 1538180 1% /dev
devpts 0 0 0 - /dev/pts
tmpfs 619612 1088 618524 1% /run
none 5120 0 5120 0% /run/lock
none 1549020 144 1548876 1% /run/shm
binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
rpc_pipefs 0 0 0 - /run/rpc_pipefs
nfsd 0 0 0 - /proc/fs/nfsd
Using df with the –total flag will show the drive spaces as well. The total space of all the drives together.
[email protected]:~$ df -h --total
Filesystem Size Used Avail Use% Mounted on
/dev/sdc1 550G 121G 402G 24% /
udev 1.5G 12K 1.5G 1% /dev
tmpfs 606M 1.1M 605M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.5G 144K 1.5G 1% /run/shm
total 553G 121G 405G 23%
Using the -i flag will show the number of inodes on the drives. Inodes are the number of files and directories the disk contains.
[email protected]:~$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdc1 36028416 525729 35502687 2% /
udev 210007 628 209379 1% /dev
tmpfs 215421 607 214814 1% /run
none 215421 5 215416 1% /run/lock
none 215421 4 215417 1% /run/shm
The -T flag can also be added to show the filesystem type, such as ext3 or NTFS.
[email protected]:~$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sdc1 ext4 575758492 126365408 420575012 24% /
udev devtmpfs 1538192 12 1538180 1% /dev
tmpfs tmpfs 619612 1088 618524 1% /run
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 1549020 144 1548876 1% /run/shm
The df command also has a couple other options, but I won’t be covering those today since the aren’t usually needed regularly. The help info for the df command is below for reference.
Usage: df [OPTION]... [FILE]...20 0 5120 0% /run/lockShow information about the file system on which each FILE resides,
or all file systems by default.
Mandatory arguments to long options are mandatory for short options too.
-a, --all include dummy file systems
-B, --block-size=SIZE scale sizes by SIZE before printing them. E.g.,
`-BM' prints sizes in units of 1,048,576 bytes.
See SIZE format below.
--total produce a grand total
-h, --human-readable print sizes in human readable format (e.g., 1K 234M
-H, --si likewise, but use powers of 1000 not 1024
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (defau
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
Report df bugs to [email protected]
GNU coreutils home page:
General help using GNU software:
For complete documentation, run: info coreutils 'df invocation'
Know some other things you can do with the df command? Tell us about it in the comments!
Chris March 18th, 2013
Posted In: General
Tags: df, disk space, drive, drive space, file system, file systems, inodes, Linux, space
Normally by default, your history will show just the number of the command that was run and the command.
[email protected] [~]# history | head
10 top
11 df -h
12 hostname -i
There are many times that you will want the time and date as well though, such as for server auditing and security reasons. To enable this, you will need to export HISTTIMEFORMAT.
[email protected] [~]# export HISTTIMEFORMAT=’%F %T ‘
This will enable the time stamps as well in your history. Now, when you run the history command, you will get something that looks like the following.
[email protected] [~]# history | head
10 2011-10-11 12:03:26 top
11 2011-10-11 12:03:29 df -h
12 2011-10-11 12:03:35 hostname -i
Let us know how you have your history set up in the comments!
Chris October 11th, 2011
Posted In: How To
Tags: 2011-10-11 12:03:26, date, df, history, history command, histtimeformat, security reasons, time