Pin Me

Monitoring Disk Space in Linux

written by: Ada Stoy•edited by: Lamar Stonecypher•updated: 6/20/2010

Linux disk space usage can be checked from the prompt if you use the appropriate commands or with the help of graphical tools. Needless to say, graphical tools for Linux disk space are easier to use, but shell commands can give you more information.

  • slide 1 of 3

    How is Linux Disk Space Organized?

    Before we proceed with the ways to check Linux disk space, there are some basic things about how Linux disk space is organized to discuss first. As any disk, a Linux disk can be divided into partitions. Partitions are logical divisions – you have the same physical hard disk but with the help of special software you divide it into separate partitions, which contain different stuff (i.e. system folders, work documents, movies, etc.).

    Partitions are created with various programs, for instance GParted. When you display Linux disk space data, you will see your partitions listed as /dev/hda3, /dev/hda1, /dev/sda1, etc. Unlike Windows, there are no drive letters in Linux; this could be a bit confusing for a newbie to figure out which partition is for the particular type of data.

  • slide 2 of 3

    Commands to check Linux disk space

    Basically, there are 2 ways in which you can check Linux disk space – from the Linux shell or with the help of an application.

    There are several commands to show Linux disk space. df, du, ls, and vmstat are common but actually the df command is used most. The simplest way to get Linux disk space data is to run the df command without any parameters. The output will be similar to this one:

    Filesystem 1K-blocks Used Available Use% Mounted on

    /dev/sda3 26794360 2872440 22560816 12% /

    tmpfs 512956 0 512956 0% /lib/init/rw

    udev 10240 2884 7356 29% /dev

    tmpfs 512956 4 512952 1% /dev/shm

    shmfs 512956 12 512944 1% /lib/init/rw/splashy

    /dev/sdb1 123908 23 123885 1% /media/USB STICK

    /dev/sda4 113396196 34699724 72843192 33% /mnt/sda4

    You see the devices and the partitions on them, their size in kilobytes, the amount of free and used space (and the ratio between the two) and the mount point. However, this way of presenting Linux disk space data isn't very handy. This is why you might want to use the -h option instead. The -h option gives the sizes in megabytes and is much handier. Here is the output for the df -f command for the same disk:

    Filesystem Size Used Avail Use% Mounted on

    /dev/sda3 26G 2.8G 22G 12% /

    tmpfs 501M 0 501M 0% /lib/init/rw

    udev 10M 2.9M 7.2M 29% /dev

    tmpfs 501M 4.0K 501M 1% /dev/shm

    shmfs 501M 12K 501M 1% /lib/init/rw/splashy

    /dev/sdb1 122M 23K 121M 1% /media/USB STICK

    /dev/sda4 109G 34G 70G 33% /mnt/sda4

    There are other options for the df command and they could also be useful. These options are more advanced and they give more detailed information, so you may want to check them in the docs section devoted to the df command.

  • slide 3 of 3

    Applications to check Linux disk space

    The second way to check Linux disk space is with the help of a graphical application. There are tons of such applications and they vary depending on the environment you choose (i.e. Gnome, KDE, or something else) and the particular Linux distribution you are using. One popular tool is Disk Usage Analyzer, which is found in Ubuntu and some other Debian distributions. Another tool you can find in many distributions is KDiskFree, which is shown in the screenshot below:

    It is up to you to decide which way to check Linux disk space. For some people a console is the place they live in and this is why it is only natural that they prefer the shell, while for others a GUI is the better option.