Linux Check Disk Space Command To View System Disk Usage

See all GNU/Linux related FAQ
I recently switched from a Windows server to a Linux server operating system and need Linux check disk space command. I am using Ubuntu 16.04/18.04/20.04 and CentOS 7.x/8.x server. How do I find out disk space utilization information using Linux command line option?

Linux commands to check disk space using:

  • df command – Shows the amount of disk space used and available on Linux file systems.
  • du command – Display the amount of disk space used by the specified files and for each subdirectory.
  • btrfs fi df /device/ command – Show disk space usage information for a btrfs based mount point/file system.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux terminal
Category Disk Management
OS compatibility AlmaLinux Alpine Arch Debian Fedora Linux Mint openSUSE Pop!_OS RHEL Rocky Stream SUSE Ubuntu
Est. reading time 9 minutes

Linux check hard disk space with df command

Try any one of the following commands to check hard disk space on Linux:

  1. Open the terminal and type the following command to check disk space.
  2. The basic syntax for df is:
    $ df [options] [devices]
  3. Next, Linux check disk space with df command:
    $ df
    $ df -H
  4. The items in square brackets are optional. You can simply type the df command (i.e. no arguments), to see a table that lists for each device name on the system.
Fig.01: Linux check disk space with df command

Fig.01: df command in action

See information about specific filesystem

You can give a device or mount point as an argument, and df report data only for the filesystem physically residing on that device. For example, the following command provides information only for the partition /dev/sda:
# Linux Check Disk Space for /dev/sda #
$ df /dev/sda
$ df -h /dev/sdc1
$ df /data/

/dev/sda (my first SATA) check disk space usage displayed as follows:

Filesystem      1K-blocks     Used  Available Use% Mounted on
/dev/sda       2930266584 69405248 2859579472   3% /data

You check nvme disk space usage too on Linux. For example, try /dev/nvme0n1p2 partion:
$ df -h /dev/nvme0n1p2
PCI NVME Linux disk space usage:

Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2  1.5G  348M  1.1G  26% /boot

Understanding df command output

The valid fields are as follows:

Display name Valid field name (for --output option) Description
Filesystem source The source of the mount point, usually a device for your Linux disk.
1K-blocks size Total number of blocks under Linux disk space.
Used used Number of used blocks on Linux disk.
Available avail Number of available blocks on Linux disk.
Use% pcent Percentage of USED divided by SIZE.
Mounted on target The mount point for your Linux disk space.

You can pass the output format defined by ‘valid field name’ as follows to get detailed view when checking disk space under Linux too. For example, try:
$ df --output=field1,field2,...
$ df --output=source,used,avail /data/

Sample outputs:

Filesystem                    Used Avail
/dev/md0                      5.4G  115G
udev                             0   11M
tmpfs                         6.2M  414M
tmpfs                         4.1k  1.1G
tmpfs                         4.1k  5.3M
tmpfs                            0  1.1G
/dev/md2                      818G  688G
tmpfs                            0  210M
tmpfs                            0  210M
/dev/mapper/cryptvg-mybackup   77G  526G

Displying all fields when checking disk space usage on Linux

Want to print all available fields? Pass the following option to the df command:
$ df --o
Detailed outputs about my Linux disk space including Inodes:

Filesystem     Type     Inodes  IUsed  IFree IUse%  1K-blocks     Used      Avail Use% File Mounted on
udev           devtmpfs 379248    333 378915    1%      10240        0      10240   0% -    /dev
tmpfs          tmpfs    381554    498 381056    1%     610488     9704     600784   2% -    /run
/dev/sdc1      ext3     956592 224532 732060   24%   14932444  7836056    6331204  56% -    /
tmpfs          tmpfs    381554      1 381553    1%    1526216        0    1526216   0% -    /dev/shm
tmpfs          tmpfs    381554      4 381550    1%       5120        0       5120   0% -    /run/lock
tmpfs          tmpfs    381554     14 381540    1%    1526216        0    1526216   0% -    /sys/fs/cgroup
/dev/sda       btrfs         0      0      0     - 2930266584 69405248 2859579472   3% -    /data
tmpfs          tmpfs    381554      4 381550    1%     305244        0     305244   0% -    /run/user/0

Express df output in human readable format while listing disk space usage under Linux

Pass the -h option to see output in human readable format. You will get Linux hard disk or device space size in gigabytes or terabytes or megabytes:
$ df -h ### Human format
$ df -m ### Show output size in one-megabyte
$ df -k ### Show output size in one-kilobyte blocks (default)

Display disk size space output using inode usage instead of block usage

An inode is a data structure on a Linux file system that stores all information about file. To list inode information for Linux disk space, enter:
$ df -i
$ df -i -h

Sample outputs:

Filesystem     Inodes IUsed IFree IUse% Mounted on
udev             371K   333  371K    1% /dev
tmpfs            373K   498  373K    1% /run
/dev/sdc1        935K  220K  715K   24% /
tmpfs            373K     1  373K    1% /dev/shm
tmpfs            373K     4  373K    1% /run/lock
tmpfs            373K    14  373K    1% /sys/fs/cgroup
/dev/sda            0     0     0     - /data
tmpfs            373K     4  373K    1% /run/user/0

Find out the type of each file system displayed

Pass the -T option to display the type of each filesystems listed such as ext4, btrfs, ext2, nfs4, fuse, cgroup, cputset, and more along with Linux disk space usage and size as usual. For instence:
$ df -T
$ df -T -h
$ df -T -h /data/

The following output indicates Linux disk space usage along with filesytem type:

Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda       btrfs  2.8T   67G  2.7T   3% /data

Limit listing to file systems of given type

The syntax is:
$ df -t ext3 #Only see ext3 file system
$ df -t ext4 #Only see ext4 file system
$ df -t btrfs #Only see btrfs file system

Exclude given file system type while checking disk space usage

To list all but exclude ext2 filesystem pass the -x TYPE option, enter:
$ df -x ext2
To hide squashfs filesystem spam on Ubuntu Linux while chcking disk space usage created by snap pacakges:
$ df -x squashfs

Checking all Linux disk space report

Pass the -a or --all option to the df command to include all possible filesystem and disk spaces. For example:
$ df -a
Here is what I see:

Filesystem      1K-blocks     Used  Available Use% Mounted on
sysfs                   0        0          0    - /sys
proc                    0        0          0    - /proc
udev                10240        0      10240   0% /dev
devpts                  0        0          0    - /dev/pts
tmpfs              610488     9708     600780   2% /run
/dev/sdc1        14932444  7836084    6331176  56% /
securityfs              0        0          0    - /sys/kernel/security
tmpfs             1526216        0    1526216   0% /dev/shm
tmpfs                5120        0       5120   0% /run/lock
tmpfs             1526216        0    1526216   0% /sys/fs/cgroup
cgroup                  0        0          0    - /sys/fs/cgroup/systemd
pstore                  0        0          0    - /sys/fs/pstore
cgroup                  0        0          0    - /sys/fs/cgroup/cpuset
cgroup                  0        0          0    - /sys/fs/cgroup/cpu,cpuacct
cgroup                  0        0          0    - /sys/fs/cgroup/blkio
cgroup                  0        0          0    - /sys/fs/cgroup/memory
cgroup                  0        0          0    - /sys/fs/cgroup/devices
cgroup                  0        0          0    - /sys/fs/cgroup/freezer
cgroup                  0        0          0    - /sys/fs/cgroup/net_cls,net_prio
cgroup                  0        0          0    - /sys/fs/cgroup/perf_event
systemd-1               -        -          -    - /proc/sys/fs/binfmt_misc
fusectl                 0        0          0    - /sys/fs/fuse/connections
debugfs                 0        0          0    - /sys/kernel/debug
mqueue                  0        0          0    - /dev/mqueue
hugetlbfs               0        0          0    - /dev/hugepages
/dev/sda       2930266584 69405248 2859579472   3% /data
rpc_pipefs              0        0          0    - /run/rpc_pipefs
tmpfs              305244        0     305244   0% /run/user/0
binfmt_misc             0        0          0    - /proc/sys/fs/binfmt_misc

These file systems omitted by default.

Getting more help about the df command

Pass the --help option see a brief help message about checking disk space command usage on Linux:
$ df --help
Or read its man page by typing the following man command:
$ man df

Linux check disk space with the du command

The du command is very useful to track down disk space hogs. It is useful to find out the names of directories and files that consume large amounts of space on a disk. The basic syntax is:
$ du
$ du /path/do/dir
$ du [options] [directories and/or files]

To see the names and space consumption of each of the directories including all subdirectories in the directory tree, enter:
$ du
Sample outputs:

16	./.aptitude
12	./.ssh
56	./apcupsd
8	./.squidview
4	./kernel.build
12	./.elinks
8	./.vim
8	./.config/htop
12	./.config
648	.

The first column is expressed in kilobytes (file size) and the second column is the filename or directory name.

See du output in human readable format

Pass the -h option to display size in K (kilobytes), M (megabytes), G (gigabytes) instead of the default kilobytes:
$ du -h
Sample outputs:

16K	./.aptitude
12K	./.ssh
56K	./apcupsd
8.0K	./.squidview
4.0K	./kernel.build
12K	./.elinks
8.0K	./.vim
8.0K	./.config/htop
12K	./.config
648K	.

Finding information about any directory trees or files

To find out /etc/ directory space usage, enter:
$ sudo du /etc/
$ sudo du -h /etc/

The following will report the sizes of the thee files named hdparm, iptunnel and ifconfig that are located in the /sbin directory:
$ du /sbin/hdparm /sbin/iptunnel /sbin/ifconfig
$ du -h /sbin/hdparm /sbin/iptunnel /sbin/ifconfig

Sample outputs:

112K	/sbin/hdparm
24K	/sbin/iptunnel
72K	/sbin/ifconfig

How do I summarize disk usage for given directory name?

Pass the -s option to the du command. In this example, ask du command to report only the total disk space occupied by a directory tree and to suppress subdirectories:
$ sudo du -s /etc/
$ sudo du -sh /etc/

Sample outputs:

6.3M	/etc/

Pass the -a (all) option to see all files, not just directories:
# du -a /etc/
# du -a -h /etc/

Sample outputs:

4.0K	/etc/w3m/config
4.0K	/etc/w3m/mailcap
12K	/etc/w3m
4.0K	/etc/ConsoleKit/run-seat.d
4.0K	/etc/ConsoleKit/seats.d/00-primary.seat
8.0K	/etc/ConsoleKit/seats.d
4.0K	/etc/ConsoleKit/run-session.d
20K	/etc/ConsoleKit
...
....
..
...
4.0K	/etc/ssh/ssh_host_rsa_key
4.0K	/etc/ssh/ssh_host_rsa_key.pub
4.0K	/etc/ssh/ssh_host_dsa_key
244K	/etc/ssh/moduli
4.0K	/etc/ssh/sshd_config
272K	/etc/ssh
4.0K	/etc/python/debian_config
8.0K	/etc/python
0	/etc/.pwd.lock
4.0K	/etc/ldap/ldap.conf
8.0K	/etc/ldap
6.3M	/etc/

You can also use star ( * ) wildcard, which will match any character. For example, to see the size of each png file in the current directory, enter:
$ du -ch *.png

 52K	CIQTK4FUAAAbjDw.png-large.png
 68K	CX23RezWEAA0QY8.png-large.png
228K	CY32cShWkAAaNLD.png-large.png
 12K	CYaQ3JqU0AA-amA.png-large.png
136K	CYywxDfU0AAP2py.png
172K	CZBoXO1UsAAw3zR.png-large.png
384K	Screen Shot 2016-01-19 at 5.49.21 PM.png
324K	TkamEew.png
8.0K	VQx6mbH.png
 64K	fH7rtXE.png
 52K	ipv6-20-1-640x377.png
392K	unrseYB.png
1.8M	total

The -c option tells du to display grand total.

Putting it all together

To list top 10 directories eating disk space in /etc/, enter:
# du -a /etc/ | sort -n -r | head -n 10
Sample outputs:

8128	/etc/
928	/etc/ssl
904	/etc/ssl/certs
656	/etc/apache2
544	/etc/apache2/mods-available
484	/etc/init.d
396	/etc/php5
336	/etc/sane.d
308	/etc/X11
268	/etc/ssl/certs/ca-certificates.crt

For more information on the du command, type:
$ man du
$ du --help

Dealing with btrfs file system

For btrfs filesystem use the btrfs fi df command to see space usage information for a mount point. The syntax is:

btrfs filesystem df /path/
btrfs fi df /dev/path
btrfs fi df [options] /path/

Examples

Let us try some examples:
$ sudo btrfs fi df /data/
$ sudo btrfs fi df -h /data/

Sample outputs:

Data, RAID1: total=71.00GiB, used=63.40GiB
System, RAID1: total=8.00MiB, used=16.00KiB
Metadata, RAID1: total=4.00GiB, used=2.29GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

To see raw numbers in bytes, run:
$ sudo btrfs fi df -b /data/
OR
$ sudo btrfs fi df -k /data/ ### show sizes in KiB ##
$ sudo btrfs fi df -m /data/ ### show sizes in MiB ##
$ sudo btrfs fi df -g /data/ ### show sizes in GiB ##
$ sudo btrfs fi df -t /data/ ### show sizes in TiB ##

Conclusion

Here is quick summary for Linux check disk space commands. Use the du command when you need to estimate file space usage. To report Linux file system disk space usage use the df command. The btrfs df command must be used when using btrfs file system. Fore more info see GNU coreutils page here. You can read man pages locally too. Just try the following help command or man command:
$ man du
$ man df
$ man btrfs

See also

This entry is 2 of 14 in the Linux & Unix Resource Utilization Tutorial series. Keep reading the rest of the series:
  1. How Do I Find Out Linux CPU Utilization and Usage?
  2. Linux Check Disk Space Command To View System Disk Usage
  3. How to check memory utilization in Linux
  4. 30 Linux System Monitoring Tools Every SysAdmin Should Know
  5. Check Swap Usage Size and Utilization in Linux
  6. How do I find out Linux Disk utilization?
  7. Top 7 Linux GPU Monitoring and Diagnostic Commands Line Tools
  8. How do I find out Linux Resource utilization to detect system bottlenecks?
  9. Linux See Bandwidth Usage Per Process With Nethogs Tool
  10. Summarize detailed system resource usage for given command on a Linux/Unix
  11. Howto collect Linux system utilization data into a file
  12. Linux Display Bandwidth Usage on Network Interface By Host
  13. Ubuntu install vnstat console network traffic monitor
  14. Linux find each multiple SMP CPU processors utilization individually

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

7 comments… add one
  • rick Jan 23, 2016 @ 18:27

    Nice article. What about “ncdu”
    For graphical overview… :)

  • Elkezo Feb 24, 2016 @ 14:27

    Hi Team,

    How do i format a 39TB drive with ext4?
    web-a1 ~]# mkfs.ext4 /dev/sda
    mke2fs 1.41.12 (17-May-2010)
    /dev/sda is entire device, not just one partition!
    Proceed anyway? (y,n) y
    mkfs.ext4: Size of device /dev/sda too big to be expressed in 32 bits
    using a blocksize of 4096.

    then Mount this partition to a folder

  • Elkezo Feb 24, 2016 @ 14:28

    Sorry wrong place

    • sunil Jan 16, 2017 @ 8:34

      haha.. I know that.. I too faced the same :D

  • Tom Schmidt Dec 5, 2020 @ 12:32

    For a MUCH more user-friendly graphical version, use QDirStat

    https://github.com/shundhammer/qdirstat

  • Bala Aug 7, 2022 @ 15:41

    May need to cover others like lsblk, disk?

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.