Both Linux and UNIX-like systems offers two commands for checking out free disk space:
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | None |
Time | 1m |
(b) du command : Estimate file space usage.
df command examples to check free disk space
Type df -h or df -k to list free disk space:
$ df -h
OR
$ df -k
Sample outputs that show disk space utilization:
Filesystem Size Used Avail Use% Mounted on /dev/sdb1 20G 9.2G 9.6G 49% / varrun 393M 144k 393M 1% /var/run varlock 393M 0 393M 0% /var/lock procbususb 393M 123k 393M 1% /proc/bus/usb udev 393M 123k 393M 1% /dev devshm 393M 0 393M 0% /dev/shm lrm 393M 35M 359M 9% /lib/modules/2.6.20-15-generic/volatile /dev/sdb5 29G 5.4G 22G 20% /media/docs /dev/sdb3 30G 5.9G 23G 21% /media/isomp3s /dev/sda1 8.5G 4.3G 4.3G 51% /media/xp1 /dev/sda2 12G 6.5G 5.2G 56% /media/xp2 /dev/sdc1 40G 3.1G 35G 9% /media/backup
The df utility displays statistics about the amount of free disk space on the specified file system or on the file system of which file is a part. Values are displayed in 512-byte per block counts. The -H option is called as “Human-readable” output. It use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 10 for sizes i.e. you see 30G (30 Gigabyte).
How to check free disk space in Linux
To see the file system’s complete disk usage pass the -a option:
df -a
Find out disk usage and filesystem type by passing the -T option:
df -T
Want to get used and free inodes information on Linux? Try:
df -i
du command examples for checking free and used disk space
The du command shows how much space one ore more files or directories is using, enter:
$ du -sh
Sample outputs:
Fig.01: Unix df and du command outputs from my FreeBSD server
Say hello to ncdu command
ncdu (NCurses Disk Usage) is a curses-based version of the well-known ‘du’, and provides a fast way to see what directories are using your disk space. One can install with the following apt command/apt-get command:
sudo apt install ncdu
For RHEL/CentOS, first enable EPEL repo (see CentOS 8 turn on EPEL repo and RHEL 8 enable epel repo) and type the following yum command:
sudo yum install ncdu
Now just type:
ncdu
ncdu [dir]
ncdu /etc/
GUI program
Above programs are good if GUI is not installed or you are working with remote system over the ssh based session. Linux and UNIX-like oses comes with KDE and Gnome desktop system. You will find Free Disk Space Applet located under GUI menus. Here is a sample from Fedora Linux version 22 system:
- Disk Usage Analizer
- Disk Usage Analizer For / File System
Conclusion
You learned how to keep track of disk utilization, and disk space with various Linux and Unix commands.
- Linux Check Disk Space Command To View System Disk Usage
- Shell script to watch the disk space
- Why command df and du reports different output?
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 58 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks it was very useful.
Thanks it was usefull, but sent mails to me i can learn morelly pls
Really very helpful.
Thanks.
Very useful
Really very helpful
how can i check free space in my hard drive after linux instalation.
fdisk -l | grep “Disk”
Thanks, it was very helpful.
It was very helped me.
Thanks a lot….
Very useful…
Very good and helped me.
Thanks
Hassan
Excellent, It really helped me alot
i love it
Thanks for this
Thanks for your gud work
Thank you very much……clear solution are always appreciated.
Thanks…made the task easy….:)
How do i check the total size of the disk on HP ES45 server, not free space, what i mean is the total size of the disk on the said server.
by using lsblk command
yes, Its helpful, but I have a directory called /dev/sda5
and its using 40% space, and I can’t identify, what is there in it, can you tell me how to look into it.
Probably SWAP.
Also, yes, I replied to you 5 years too late.
Another Informative article. I enjoyed it very much. Erin Deliso
Too Good article !! Keep up the work !!
Thanks a lot. It’s very useful.
Simple and informative. Thanks! :)
Its very useful
thanks , short and useful
thanks for sharing!
This is really nice article and help full to diagnose the issue in the server.
Thanks..helped a lot
thanks, helps a lot.
Thank for sharing. it helped a lot
Thanks, it was helpful
thanks for sharing…
Excellent! it really helped me a lot…
thanks. it was clear and useful article without any complexity.
Thanks. Appreciated the info.
Thanks a lot.
very useful…
thanks very usefull for me newbie on linux :D
Hi when I give command df -h output shows tmpfs contains 4 gigs space. Is it possible and harmless to free-up this space?
tnx it was good
so simple an helpful , amazing Rom
Nice summary just what i needed
brilliant! it really helped me a lot…
How can i find out the disk size of this file system zharh10a.oracle.
Thank You. Just needed info for every one to simply find what they usual need in unix
Thank you, loved it,
clean clean clean and clean,
love u
cheers
really helped a lot.
Cheers
For total hard disk size fdisk -l | grep Disk use this command
Thanks!! It was usefull
Thanks a lot!! It’s really useful.
Thanks a lot.
try ncdu!
If you have privileges to install binarys on your system time and are frequently going to be looking at your disk usage ncdu is an extreemly fast ncurses tool for exploring disk usage and much easier to use than du!
manual:
https://dev.yorhel.nl/ncdu/man
screenshots:
https://dev.yorhel.nl/ncdu/scr
This is the best tool ever!
Hi
Thanks, how to split it user wise. Like, I want which user uses how much of the space.
How to view unallocated free space on a hard disk?