How to check disk space in Linux?
I'm running Linux on my system and need to quickly check my available disk space. What commands or methods can I use to clearly see disk usage?
I ran into this the other day, I needed to check how much space was left on my Linux VPS system, and here’s what worked for me.
View Linux Disk Usage with the df -h Command
First, I used this:
df -h
It shows your drives, how big they are, how much is used, and what’s still free. You’ll get something like:
FS Size Used Free Use% Mount
/dev/sdb1 80G 55G 21G 70% /
Pretty handy.
Want to dig deeper? The Linux manual for df explains all the options in detail.
Then, I wanted to see how much space a specific folder was taking up. For that, this command did the trick:
du -sh /var/log
Run a Disk Space Command to Check Folder Size
Mine showed:
2.4G /var/log
So yeah, 2.4 gigs just for log files. Not bad, but good to know.
Hope that helps. If you’re running out of space, these two commands are lifesavers.