Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to check total space and available space in Linux using the terminal?
In Linux/Unix systems, the df (disk free) command is the primary tool for checking storage details and disk space usage. It displays total space, used space, and available space for mounted file systems through the terminal.
df (disk free) command
The df command reports file system disk space usage in the Linux system. By default, it shows space usage in 1K blocks, but various options make the output more readable and useful for different purposes.
Syntax
The general syntax of the df command is as follows:
$ df [OPTION]... [FILE]...
Common Options
| Option | Description |
|---|---|
| -h, --human-readable | Display sizes in powers of 1024 (K, M, G) |
| -H, --si | Display sizes in powers of 1000 (KB, MB, GB) |
| -T, --print-type | Display file system type |
| -a, --all | Include all file systems, including dummy ones |
| -l, --local | Show only local file systems |
| -x, --exclude-type=TYPE | Exclude file systems of specified type |
| --help | Display help message and exit |
| --version | Show version information and exit |
Basic Usage
To check basic disk space usage, run the df command without any options:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 20960256 8234567 11718888 42% / /dev/sda5 1048576 524288 495616 52% /home tmpfs 2097152 0 2097152 0% /tmp
The default output shows space in 1K blocks, which can be difficult to interpret. The numbers represent kilobytes but lack clear units.
Human-Readable Format
To display output in an easily understandable format, use the -h option:
$ df -h
Filesystem Size Used Avail Use% Mounted on /dev/sda1 21G 8.1G 12G 42% / /dev/sda5 1024M 512M 485M 52% /home tmpfs 2.1G 0 2.1G 0% /tmp
This format uses familiar units like G (gigabytes), M (megabytes), and K (kilobytes) in powers of 1024.
SI Units Format
To display storage in powers of 1000 (decimal), use the -H option:
$ df -H
Filesystem Size Used Avail Use% Mounted on /dev/sda1 22G 8.4G 12G 42% / /dev/sda5 1.1G 537M 507M 52% /home tmpfs 2.2G 0 2.2G 0% /tmp
File System Type Information
To include file system types in the output, combine -h with -T:
$ df -hT
Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 21G 8.1G 12G 42% / /dev/sda5 ext4 1024M 512M 485M 52% /home tmpfs tmpfs 2.1G 0 2.1G 0% /tmp
Key Points
The
-hoption is most commonly used for readable output in binary units (1024-based).The
-Hoption displays decimal units (1000-based), similar to storage manufacturer specifications.The Use% column shows the percentage of used space, helping identify full partitions quickly.
The Mounted on column indicates where each file system is mounted in the directory tree.
Conclusion
The df command is essential for monitoring disk space usage in Linux systems. Using the -h option provides human-readable output, making it easy to quickly assess available storage space and identify partitions that may need attention.
