1

What's a single command I can run that shows me the total amount of space free on a hard drive? I don't want to do any math, I just want a command that shows me the total free space on my hard drive.

  • You can use df – 123 Feb 2 '16 at 9:33
  • 2
    You can also try 'parted' then 'print free' -- Source. – Dean Feb 2 '16 at 9:37
  • Thanks peeps for the df commands, though those weren't exactly what I was looking for, nor was 'parted'. I was wanting a total via commands, not to have to self total to get a total. – DeJeL Feb 2 '16 at 10:08
  • @DeJeL I think you should amend your question to better explain what you want. I assume you mean the free space totaled for all filesystems on several partitions on a specified hard drive. (Should that include only mounted filesystems? What about partitions mounted via device-mapper? What about logical volumes? Swap space?) – Dubu Feb 2 '16 at 12:07
4

You can use df with the total flag

--total
produce a grand total

df --total

or

df --total -h

for human readable output (i.e K,M,G)

This wil produce output such as

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        23G   13G  8.7G  60% /
udev            4.0G  124K  4.0G   1% /dev
tmpfs           4.0G   72K  4.0G   1% /dev/shm
total            31G   13G   17G  44%

To only show the total for physical harddisk space(including nfs)

df -x tmpfs --total -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        23G   13G  8.7G  60% /
total            23G   13G  8.7G  60%

Depending on which filetypes you want to exlude (as udev appears to be able to be either tmpfs or devtmpfs) you can use

df -T
Filesystem     Type  1K-blocks     Used Available Use% Mounted on
/dev/sda2      ext3   23731644 13486576   9039564  60% /
udev           tmpfs   4093900      124   4093776   1% /dev
tmpfs          tmpfs   4093900       72   4093828   1% /dev/shm
                ^
               This column

To check the filetypes and then just put the required ones into the -x command

Also note that all of these are GNU extensions so you require GNU df.

  • That "total" is misleading. You don't have 17G free in your hard drive, only 8.7. The udev and tmpfs filesystems don't count. – muru Feb 4 '16 at 8:23
  • @muru Updated to address your concern. – 123 Feb 4 '16 at 8:39
  • --exclude-type=tmpfs still shows udev (aka devtmpfs). – muru Feb 4 '16 at 8:43
  • @muru doesn't on mine, udev is tmpfs filetype udev tmpfs 4093900 124 4093776 1% /dev – 123 Feb 4 '16 at 8:45
  • Odd. It happens to me on Ubuntu 14.04 (3.13.0-74-generic) and Arch Linux (4.4.1-2-ARCH). – muru Feb 4 '16 at 8:46
4

You can use the df command:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           799M  8.7M  790M   2% /run
/dev/xvda1       50G  6.3G   41G  14% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
cgmfs           100K     0  100K   0% /run/cgmanager/fs
tmpfs           799M     0  799M   0% /run/user/1000

Here, /dev/xvda1 is my main disk, and it has 41 GB free.

You can also limit the output to only a specific disk or directory:

$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       50G  6.3G   41G  14% /
1

df (or df -h for "human readable" sizes) shows you the filesystem devices, how big are they, how much is used, how much is available, and their mount points in the system.

Take a look here if you want to see some more console commands in your Linux Mint.

  • Those other commands from that link helped me with a problem (of self control) I've been having. I loose track of time and stay up all night on my computer, the command will stop that forcefully after the time I allow myself. the command is (sudo) shutdown -h <time_in_minuets> – DeJeL Feb 2 '16 at 10:13
0

You can use pydf. It's an improved version of df.
http://linux.die.net/man/1/pydf

It produces an output like this:

Filesystem Size Used Avail Use%                 Mounted on
/dev/sdb5   92G  16G   70G 17.9 [##...........] /         
/dev/sdb6  347G  31G  298G  9.0 [#............] /home
  • Cinnamon does not start with that installed. I want a command that can do this 'cause I'm low on data. So I can't install anything. – DeJeL Feb 2 '16 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.