Managing disk space is crucial for ensuring that your Linux system runs smoothly. Without adequate space, your system can slow down, and applications may fail to function properly. The df command stands for “disk filesystem.” It is used in Linux to get a summary of available and used disk space on your file system.
Getting Started with DF
To use the df command, you need to access the terminal. You can open it by searching for “Terminal” in your applications menu or by using the shortcut Ctrl+Alt+T
.
The basic syntax for the df command is simply df
. Typing this in the terminal and pressing enter will display the disk space usage for all mounted filesystems.
df
The output will be similar to the one below:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 50620216 41487880 9115952 82% /
tmpfs 6634712 4 6634708 1% /dev/shm
tmpfs 2653888 1040 2652848 1% /run
tmpfs 5120 0 5120 0% /run/lock
/dev/sda15 106858 6186 100673 6% /boot/efi
tmpfs 1326940 4 1326936 1% /run/user/1001
Advanced DF Usage
For easier interpretation, use df -h
to display the disk space in a human-readable format, with sizes in KB, MB, or GB.
Filesystem Size Used Avail Use% Mounted on
/dev/root 49G 40G 8.7G 82% /
tmpfs 6.4G 4.0K 6.4G 1% /dev/shm
tmpfs 2.6G 1.1M 2.6G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda15 105M 6.1M 99M 6% /boot/efi
tmpfs 1.3G 4.0K 1.3G 1% /run/user/1001
You can customize the ‘df’ output to include or exclude certain filesystems using the -x
and -a
options for a more focused analysis.
df -hx tmpfs
The above command will exclude the tmpfs file system from the output and render it in human readable format.
Filesystem Size Used Avail Use% Mounted on
/dev/root 49G 40G 8.7G 82% /
/dev/sda15 105M 6.1M 99M 6% /boot/efi
Common DF Command Options
There are several options that can be used with df command, some of the commonly used options are listed below:
Option | Description |
---|---|
-h | Human-readable output |
-a | Include all filesystems |
-x | Exclude certain filesystems |
-T | Display filesystem type |
-i | Display the inodes usage |
FAQs
How do I check disk space for a specific directory?
Use df -h /path/to/directory
to see the disk space for that particular directory.
Can ‘df’ show inode information?
Yes, use df -i
to display inode usage for each filesystem.
How do I interpret the ‘Use%’ column in ‘df’ output?
The ‘Use%’ column shows the percentage of disk space that is currently being used.
What does ‘Mounted on’ mean in the ‘df’ output?
‘Mounted on’ indicates the directory in which the filesystem is accessible.
Why does ‘df’ sometimes show more space used than ‘du’?
‘df’ accounts for space used by the filesystem itself, while ‘du’ only counts files, leading to differences in reported usage.
Conclusion
This concludes the article on using the df command to check disk space usage. Feel free to leave your comment below for any clarifications.
Leave your Reply