Tracking disk usage information is a day-to-day task of any system administrator. Linux has some built-in utilities that help you find the disk space of your system.
- df command : It displays the amount of disk space used by Linux file systems.
- du command : It displays the amount of disk space used by files and directories.
In this post, we will show you how to check disk space on Linux using several ways.
Prerequisites
- A server running Linux operating system.
- A root password is configured on the server.
Check Disk Space Using the df Command
You can use the df command without any argument to check the disk space usage of mounted file systems.
df
You should se the following output:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 288237920 35699668 237873500 14% /
none 4 0 4 0% /sys/fs/cgroup
udev 1950372 4 1950368 1% /dev
tmpfs 392664 4548 388116 2% /run
none 5120 0 5120 0% /run/lock
none 1963312 150760 1812552 8% /run/shm
none 102400 48 102352 1% /run/user
/dev/sda5 187308940 37156240 140614908 21% /Data
/dev/loop0 93568 93568 0 100% /snap/core/8592
/dev/loop1 177536 177536 0 100% /snap/skype/112
/dev/loop2 93568 93568 0 100% /snap/core/8689
/dev/loop3 46080 46080 0 100% /snap/gtk-common-themes/1440
/dev/loop4 56064 56064 0 100% /snap/core18/1668
/dev/loop5 177664 177664 0 100% /snap/skype/115
/dev/loop6 164096 164096 0 100% /snap/gnome-3-28-1804/116
/dev/loop7 56832 56832 0 100% /snap/teams-for-linux/79
A brief explanation of each column is shown below:
- Filesystem: Display the name of the file system partition.
- 1K-blocks: Display the size of the filesystem in 1K blocks.
- Used: Display the used space.
- Available: Display the available space.
- Use%: Display the used space in percentage.
- Mounted on: Display the directory on which the filesystem is mounted.
Show Disk Space in Human Readable Format
If you want to display disk space usage in human readable format, use the dh command with h option.
df -h
You should get the following output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 275G 35G 227G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.9G 4.0K 1.9G 1% /dev
tmpfs 384M 4.7M 379M 2% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.9G 160M 1.8G 9% /run/shm
none 100M 48K 100M 1% /run/user
/dev/sda5 179G 36G 135G 21% /Data
/dev/loop0 92M 92M 0 100% /snap/core/8592
/dev/loop1 174M 174M 0 100% /snap/skype/112
/dev/loop2 92M 92M 0 100% /snap/core/8689
/dev/loop3 45M 45M 0 100% /snap/gtk-common-themes/1440
/dev/loop4 55M 55M 0 100% /snap/core18/1668
/dev/loop5 174M 174M 0 100% /snap/skype/115
/dev/loop6 161M 161M 0 100% /snap/gnome-3-28-1804/116
/dev/loop7 56M 56M 0 100% /snap/teams-for-linux/79
Display File System Type
You can use the df command with the option T to display file system type with other information.
df -T
You should see the following output:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 288237920 35700492 237872676 14% /
none tmpfs 4 0 4 0% /sys/fs/cgroup
udev devtmpfs 1950372 4 1950368 1% /dev
tmpfs tmpfs 392664 4976 387688 2% /run
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 1963312 223944 1739368 12% /run/shm
none tmpfs 102400 48 102352 1% /run/user
/dev/sda5 ext4 187308940 37156240 140614908 21% /Data
/dev/loop0 squashfs 93568 93568 0 100% /snap/core/8592
/dev/loop1 squashfs 177536 177536 0 100% /snap/skype/112
/dev/loop2 squashfs 93568 93568 0 100% /snap/core/8689
/dev/loop3 squashfs 46080 46080 0 100% /snap/gtk-common-themes/1440
/dev/loop4 squashfs 56064 56064 0 100% /snap/core18/1668
/dev/loop5 squashfs 177664 177664 0 100% /snap/skype/115
/dev/loop6 squashfs 164096 164096 0 100% /snap/gnome-3-28-1804/116
/dev/loop7 squashfs 56832 56832 0 100% /snap/teams-for-linux/79
To display the information about ext4 partition, run the following command:
df -t ext4
You should see the following output:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 288237920 35700936 237872232 14% /
/dev/sda5 187308940 37156240 140614908 21% /Data
Check Disk Space Usage with du Command
You can also use the du command to check the disk space usage in Linux system.
Run the du command without any argument will display the disk space usage of your current directory:
du
You should see the following output:
308 ./.anydesk/thumbnails
1256 ./.anydesk
164 ./.gftp
4 ./.xx-svn-diff
4 ./Public
4 ./.local/share/folks
12 ./.local/share/data/Nextcloud
16 ./.local/share/data
4 ./.local/share/gstreamer-1.0/presets
8 ./.local/share/gstreamer-1.0
20 ./.local/share/unity-webapps
8 ./.local/share/vlc
4 ./.local/share/evolution/calendar/trash
8 ./.local/share/evolution/calendar/system
16 ./.local/share/evolution/calendar
4 ./.local/share/evolution/mail/trash
8 ./.local/share/evolution/mail
4 ./.local/share/evolution/memos/trash
To display the information in human readable format, run the following command:
du -h
You should see the following output:
308K ./.anydesk/thumbnails
1.3M ./.anydesk
164K ./.gftp
4.0K ./.xx-svn-diff
4.0K ./Public
4.0K ./.local/share/folks
12K ./.local/share/data/Nextcloud
16K ./.local/share/data
4.0K ./.local/share/gstreamer-1.0/presets
8.0K ./.local/share/gstreamer-1.0
20K ./.local/share/unity-webapps
8.0K ./.local/share/vlc
4.0K ./.local/share/evolution/calendar/trash
8.0K ./.local/share/evolution/calendar/system
16K ./.local/share/evolution/calendar
You can use the du command with -hs option to display the total disk space usage of the specified directory.
du -hs /var/log
You should see the following output:
18M /var/log
You can also use the du command with sort parameter to sort the files and directories by size as shown below:
du -h | sort -rn
You should see the following output:
136K ./master-pdf-editor-4/lang/qt
124K ./master-pdf-editor-5/stamps/Standard
124K ./master-pdf-editor-4/stamps/Standard
80K ./master-pdf-editor-5/templates
80K ./master-pdf-editor-4/templates
77M ./HD-Wallpaper
76K ./master-pdf-editor-5/templates/stamps
76K ./master-pdf-editor-4/templates/stamps
64M ./Mummy
52K ./111
48M ./master-pdf-editor-5
44M ./master-pdf-editor-4
19M ./master-pdf-editor-5/lang
15M ./master-pdf-editor-4/lang
12M ./Webserver
Conclusion
In the above guide, you learned how to check disk space usage with the du and df command. I hope this will help you in your day-to-day task.