783

Is there a way to quickly check the amount of free / used disk space in Ubuntu?

I would assume you could right click on 'file system' in the file browser and choose 'properties' or something but there is no such option.

0

18 Answers 18

795

Open System Monitor from Dash and select the Filesystems tab.

enter image description here

Or alternatively open a Terminal and type:

df -h
8
  • 8
    thanks! got me what i need. But it is kind of a bummer that there's no intuitive way to check the hd usage. I imagine most people would get frustrated trying to figure it out.
    – greg
    Oct 28, 2011 at 21:11
  • 8
    Well. Every time you are in a folder in nautilus, it says at the bottom how much space is left on the device. Nov 2, 2011 at 23:15
  • 4
    @greg: Actually, it isn't as straightforward as you might think, since the UNIX way of mounting filesystems means that any folder's contents can potentially exist on different disks or partitions. Thus, any method of checking free space must explicitly account for this. Nov 3, 2011 at 3:17
  • 109
    df -h --total Mar 10, 2013 at 14:22
  • 9
    df for used and free space in bytes, df -m for space in units of 1MB, df -h for largest available unit. You will also get % usage, it remains same with all the above though.
    – Fr0zenFyr
    Jan 17, 2014 at 4:45
305

You can use baobab, or similar tools such as kdirstat or filelight, to see what files are using up your disk space.

Baobab is also called Disk Usage Analyzer on Ubuntu.

Here's a sample screenshot of baobab:

baobab

Below is a sample screenshot of filelight:

filelight

For a command line option, I prefer to use ncdu:

ncdu

You can drill into sub-folders to get total relative disk usage on the sub-folders. It's turtles all the way down. More nifty than du -sh on remote machines.

11
  • 51
    Was not aware of ncdu until now. VERY useful program. I went from issuing du -sk * | sort -n to using ncdu. While I do enjoy being able to issue a few handy commands in a terminal or even making aliases out of them, no sense reinventing the wheel.
    – Tass
    Mar 21, 2016 at 14:57
  • 17
    ncdu is a great tool, very fast, very awesome.
    – Boinst
    Jul 12, 2016 at 4:42
  • 1
    kdirstat was remade as QDirStat and it is insanely fast and an excellent graphical representation of drive / (recursive) folder usage.
    – phil294
    Feb 22, 2017 at 12:28
  • 12
    I would recommend when using ncdu to use it with the -x switch so that it doesn't try to count mounted devices in the disk space counts. ncdu -x / can show you from your root / on.
    – Terrance
    Jan 1, 2018 at 22:45
  • 2
    Here is ncdu man pages.
    – Pathros
    Mar 11, 2021 at 13:13
228

If like me all you need is the total of disk space used then just use the following command.

df -h --total

Here's a sample output with the total shown at the end

Filesystem      Size  Used Avail Use% Mounted on
udev            478M     0  478M   0% /dev
tmpfs           100M  4.5M   95M   5% /run
/dev/vda1        20G  3.3G   16G  18% /
tmpfs           497M     0  497M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           497M     0  497M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/0
total            22G  3.3G   17G  17% -

I wrote a post about it: How Do I Find the Amount of Free Space on My Hard Drive with Command Line?

1
  • df -h --total | command grep total | df -h --total | command grep total | head -c-3 && echo '' will show only the total line
    – alper
    Mar 13, 2021 at 15:28
174

gnome-system-monitor or df -h or lsblk

Other useful utilities are baobab.

2
  • 1
    Agree with user606723. Cool utility baobab :)
    – Dhaval
    Jan 9, 2014 at 11:06
  • 8
    lsblk lists the size of each partition, not the free space. Oct 23, 2018 at 23:26
30

Free/used disk space is always related to a partition

First you need to decide which partition you are interested in.

root@pc:~# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda1               28G   26G  643M  98% /
none                   4.0K     0  4.0K   0% /sys/fs/cgroup
udev                   3.9G  4.0K  3.9G   1% /dev
tmpfs                  790M  1.5M  789M   1% /run
/dev/sda6              887G  685G  158G  82% /home

In my case I am interested in the / since it has 98% in use. In other words it is nearly full.

Now I use this command to see which files and directories contain the most bytes:

root@pc:~# du -ax / | sort -rn > /var/tmp/du-root-$(date --iso).log

Above command can take some time. If you are really unlucky the result is too big for /var/tmp. Then you need an other destination. Maybe a temporary mounted usb memory stick.

Here are the first lines of my result:

root@pc:~# less /var/tmp/du-root-$(date --iso).log
26692380        /
9875188 /usr
8931652 /var
4057324 /var/log
4038176 /var/log/bootchart
3784016 /usr/share
2934248 /lib
2799204 /usr/lib
2785176 /lib/modules
2617048 /var/lib
2141124 /usr/src
1834444 /var/lib/docker
1817372 /var/lib/docker/aufs
1817076 /var/lib/docker/aufs/diff
1769612 /localhome
1338484 /tmp

Why is /var/log/bootchart that big? .... That is an other question ...

13

There are a number of ways to do this.

  • Enable the status bar in the View menu in Nautilus. This will place a bar at the bottom of all nautilus windows telling you the free space.

  • Use the File Systems System Monitor to view a list of all disks and their free space.

  • Use the Disk Usage Analyzer to get a listing of all directories on your system and how much free space they take up.

  • Go to any folder in nautilus and right click the background. Open the properties window to check the free space.

  • Run the command df -h.

1
  • Disk Usage Analyzer was what I needed, a simple Windows-style per-drive breakdown (used / total) rather than a bunch of directories which are on the same drive. Apr 24, 2018 at 22:59
13

There's df information all over the net, but I like output that's simple and easy to read.

If you run

df -h --total

the bottom line in the output will give you exactly how much is left in your system, as well as how much is used etc.

The other option is to use

df -h --total | grep total

which will show it in one line as

  • (1) total space
  • (2) total space used
  • (3) total space still available
  • (4) percentage of drive used.

All of this in gigabytes.

I mapped this to a shell command dspace and when I type that into terminal it instantly shows me my disk space usage.

You can even write little shell commands that will monitor it and alert you if you get too low etc.

7

Another way! Right click on computer in Nautilus (file explorer) and click properties. It displays how much free and used space is on your hard drive. enter image description here

1
  • is there a command for this? Dec 18, 2019 at 16:28
5

I wrote a little hack for this with a command line and gui version. It's rather hard-coded, so may need some tweaks. Also, the gui version appears to use a proportional font that messes up the alignment of the displayed output. These scripts could be put in your path somewhere (like in $HOME/bin) and you can create an icon for the gui script on your desktop or panel.

#!/bin/bash
## jdf - Copyleft 04/25/2009 - JPmicrosystems - GPL
## Free space on disk
## Custom df output
## Human readable (-h)
## sorted by file system name

## Make a temporary file and put the following awk program in it
AWK=$(/bin/mktemp -q /tmp/jdf.XXXXXX)

## PROG is quoted to prevent all shell expansions
## in the awk program
cat <<'PROG' > ${AWK}
## Won't work if mount points are longer than 21 characters

BEGIN {
  ## Use fixed length fields to avoid problems with
  ## mount point or file system names with embedded blanks
  FIELDWIDTHS = "11 11 6 6 5 5 21"
  printf "\n%s\n\n", "                    Available Disk Space"
  printf     "%s\n", "Mount Point          Avail Size  Used  Use%  Filesystem Type"
}

## Eliminate some filesystems
## That are usually not of interest
## anything not starting with a /

! /^\// { next }

## Rearrange the columns and print

{
  TYP=$2
  gsub("^ *", "", TYP)
  printf "%-21s%6s%6s%5s%5s %s%s\n", $7, $5, $3, $4, $6, $1, TYP
}

END { print "" }
PROG

df -hT | tail -n +2 | sort | gawk -f ${AWK}

rm -f ${AWK}

Sample output:

                   Available Disk Space

Mount Point          Avail Size  Used  Use%  Filesystem Type
/                      22G  30G  6.6G   24%  /dev/sda6  ext4    
/media/dataspace       44G 155G  105G   71%  /dev/sda8  ext3    
/home                 5.5G  32G   25G   82%  /dev/sda9  ext3    

Gui version:

#!/bin/bash
jdf | zenity  --title "Available Disk Space" --text-info --width=500 --height=300 --timeout=60

New Gui Version with fonts fixed using yad

#!/bin/bash

jdf | yad  --fontname="DejaVu Sans Mono 12" --title "Available Disk Space" --text-info --width=650 --height=300
3

Using dconf-editor or gsettings (sudo apt-get install dconf-tools) you can enable the default behavior of the status bar.

Type this on your terminal to enable the status bar by default

gsettings set org.gnome.nautilus.window-state start-with-status-bar true

Type this on your terminal to disable the status bar by default

gsettings set org.gnome.nautilus.window-state start-with-status-bar false

After that you will have the statusbar opened by default on Nautilus, no need to run anything else.

2

In lubuntu you can do as follows:

1- Start Button > Accessories > Disks

2- Start Button > Preferences > Disks

enter image description here

1

lsblk with some extra options works pretty well.
lsblk -o NAME,MOUNTPOINT,SIZE,FSUSED,FSAVAIL,FSUSE%

You can customize the columns. If you want more device level info add VENDOR,LABEL,UUID.

0

If you use Ubuntu with MATE DE (Ubuntu MATE) you can use MATE Disk Usage Analyzer:

  • its icon is located in Applications->System Tools
  • it is a part of mate-utils package
  • its executable is named mate-disk-usage-analyzer
  • its screenshot is presented below:

    MATE Disk Usage Analyzer

    even on latest 18.04 LTS it looks traditionally nice.

0

Filelight is the best graphical program to find out the usage of some mounted partitions. Doesn't show everything which is mounted by the system, but displays enough data which should suffice an average user. Does not require root to work, can be run as a regular user. Belongs to KDE.

enter image description here

0

Go to Utilities / Disks it will give you the percentage of use. Linux is divided in to two SDAs, the first is for the OS, the second is for the files (available space)

1
  • Note that there is a generalization in this answer: while in the past by default the installer created two partitions on the disk which will be referenced by two block devices which may be /dev/sda* for root filesystem / and swap partition ( for relocated memory pages ), the more recent versions of Ubuntu opt to have only one root partition with root filesystem and a swap file. Note also that for NVMe drives it may be /dev/nvme0n* block device Jul 25, 2020 at 6:42
0

A command-line option: parted in command mode:

$ parted /dev/nvme0n1 unit GiB print free
Model: Samsung SSD 970 EVO Plus 1TB (nvme)
Disk /dev/nvme0n1: 932GiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End      Size     File system  Name  Flags
        0.00GiB  0.00GiB  0.00GiB  Free Space
 1      0.00GiB  0.50GiB  0.50GiB  fat32              boot, esp
 2      0.50GiB  732GiB   731GiB   ext4
        732GiB   932GiB   200GiB   Free Space

$
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal
$
$ parted --version
parted (GNU parted) 3.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
$

Taken from this unix.stackexchange.com answer.

-1

If you have facing the issue in low disk space in android studio,just delete the unwanted emulator in your AVD manager.I wasted the whole to try other things.it help full to any one.it working for me.

1
  • Downvoting for the following reason: this answer does not address what is asked in this particular question. While it is a useful solution, it is not useful in this particular context. Jul 25, 2020 at 6:37
-2

Simply you can find available free space using free command .. Here you can get clear explanation about free command usage

using "free" command to find free space available on Linux

1
  • 2
    The free command is for memory, not for hard disks.
    – PerlDuck
    Sep 21, 2018 at 17:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .