How do I find out my installed hard disk size in Linux or UNIX like operating systems?
Under Linux and UNIX operating systems you can use the df command. The df command displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.
Task: Display Hard Disk Partition Size
Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
$ df
Sample outputs:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdb1 19228276 14699744 3551784 81% / tmpfs 384300 4 384296 1% /dev/shm /dev/hdb5 27917308 23883184 2615988 91% /data/network
Task: Display Hard Disk Partition Size in Mega bytes or GB or TB
Type the following command:
$ df -H
Sample outputs:
Filesystem Size Used Avail Use% Mounted on /dev/hdb1 20G 16G 3.7G 81% / tmpfs 394M 4.1k 394M 1% /dev/shm /dev/hdb5 29G 25G 2.7G 91% /data/network
Task: Display TOTAL Hard Disk Size
The fdisk command is partition table manipulator for Linux. But it can be used to display total hard disk size. You must type the following command as the root user:
# fdisk -l | grep Disk
Sample outputs:
Disk /dev/hda: 20.0 GB, 20060651520 bytes Disk /dev/hdb: 80.0 GB, 80060424192 bytes
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 14 comments… read them below or add one }
Hello Sir,
Pls verify the other userfull command for me on linux.
Thanks for the fdisk -l tip! I’ve been wondering how to see total disk size, not just partitions. Now I know!
Nice and quick, thanks!
The following command is an improvement of the Fdisk -l command, which is actually exactly what most people are looking for:
Bunny:~# fdisk -l 2> /dev/null | grep Disk | grep -v identifier
Disk /dev/sda: 60.0 GB, 60011642880 bytes
Disk /dev/sdb: 60.0 GB, 60011642880 bytes
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
…..
Disk /dev/sdv: 1000.1 GB, 1000123400192 bytes
Disk /dev/md5: 18002.2 GB, 18002220023808 bytes
hi plz how put a hard disck in a server and mirror i want the comment
> fdisk -l | egrep ‘Disk.*bytes’ | awk ‘{ sub(/,/,”"); sum +=$3; print $2″ “$3″ “$4 } END { print “—————–”; print “total: ” sum ” GB”}’
and you will get something simillar to it:
/dev/sda: 80.0 GB
/dev/sdb: 120.0 GB
/dev/sdc: 2000.4 GB
/dev/sdd: 250.1 GB
/dev/sde: 250.1 GB
—————–
total: 2700.6 GB
sir df is only work for mounted filesystem. and fdisk does’nt show any free space of the whole disk
why people need to show off with the linux command?
fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$3; print $2" "$3" "$4 } END { print "—————–"; print "total: " sum " GB"}'wut the heck..why dont you type a little bit more until it becomes some great bash romance..i think this website has explain pretty well..or maybe u can check this link
http://www.cyberciti.biz/faq/linux-viewing-drive-partitions-with-fdisk-parted/
nice and helpful…
Hi
Thanks a lot
It’s very usefull for me.
I have one question…
below mentioned command will work on AIX, FreeBSD, HPUX, IRIX,Mac OS X, NetBSD, OpenBSD,OpenVMS, POWER HMC, IBM Hardware Management Consoles ,Solaris, Tru64,UnixWare, SCO OpenServer and SCO UNIX VMware ESX VMware ESXi …………???
fdisk -l | egrep ‘Disk.*bytes’ | awk ‘{ sub(/,/,”"); sum +=$3; print $2″ “$3″ “$4 } END { print “—————–”; print “total: ” sum ” GB”}’
fdisk -l |grep Disk
Thanks ….it worked like a charm
thank u very much, great tips !!
is there a command that shows only used hard disk size??
dmesg | grep GiB