How to view free disk space and disk usage from the linux terminal

How to view free disk space and disk usage from the linux terminal

Keeping track of disk utilization information is on system administrators’ (and others’) daily to-do list. Linux has a few built-in utilities that help provide that information.

Linux df command

The df command stands for “disk-free,” and shows available and used disk space on the Linux system.

df -h shows disk space in human-readable format

df -a shows the file system’s complete disk usage even if the Available field is 0

How to view free disk space and disk usage from the linux terminal

df -T shows the disk usage along with each block’s filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)

df -i shows used and free inodes

How to view free disk space and disk usage from the linux terminal

You can get this information in a graphical view using the Disks (gnome-disk-utility) in the GNOME desktop. Launch it to see all disks detected by your computer, and click a partition to see details about it, including space used and space remaining.

How to view free disk space and disk usage from the linux terminal

Linux du command

The Linux Terminal

du shows the disk usage of files, folders, etc. in the default kilobyte size

du -h shows disk usage in human-readable format for all directories and subdirectories

du -a shows disk usage for all files

du -s provides total disk space used by a particular file or directory

How to view free disk space and disk usage from the linux terminal

The following commands will check your total space and your utilized space.

This information can be represented visually in GNOME with the Disk Usage application, or with Filelight in the KDE Plasma desktop. In both applications, disk usage is mapped to concentric circles, with the middle being the base folder (usually your /home directory, but it’s up to you) with each outer ring representing one directory level deeper. Roll your mouse over any segment for detailed information about what’s taking up space.

How to view free disk space and disk usage from the linux terminal

Linux ls -al command

ls -al lists the entire contents, along with their size, of a particular directory

How to view free disk space and disk usage from the linux terminal

Linux stat command

stat displays the size and other stats of a file/directory or a filesystem.

How to view free disk space and disk usage from the linux terminal

Linux fdisk -l command

fdisk -l shows disk size along with disk partitioning information

How to view free disk space and disk usage from the linux terminal

These are most of the built-in utilities for checking file space in Linux. There are many similar tools, like Disks (GUI), Ncdu, etc., that also show disk space utilization. Do you have a favorite tool that’s not on this list? Please share in the comments.

This article was originally published in July 2018 and has been updated to include additional information.

How to view free disk space and disk usage from the linux terminal

Check used disk space on Linux with du

Find out how much disk space you’re using with the Linux du command.

Managing disk space on a Linux server is an important task. For example, package manager applications notify you how much disk space will be required for an installation. For that information to be meaningful, you should know how much space your system has available.

In this tutorial, learn how to use the df command to check disk space in Linux and the du command to display file system disk space usage.

How to view free disk space and disk usage from the linux terminal

  • A Linux-based system
  • A terminal window / command line
  • A user account with sudo or root privileges

Check Linux Disk Space Using df Command

You can check your disk space simply by opening a terminal window and entering the following:

How to view free disk space and disk usage from the linux terminal

The df command stands for disk free, and it shows you the amount of space taken up by different drives. By default, df displays values in 1-kilobyte blocks.

Display Usage in Megabytes and Gigabytes

You can display disk usage in a more human-readable format by adding the -h option:

This displays the size in kilobytes (K), megabytes (M), and gigabytes (G).

How to view free disk space and disk usage from the linux terminal

Understanding the Output Format

The df command lists several columns:

Your output may have more entries. The columns should be self-explanatory:

  • Filesystem – This is the name of each particular drive. This includes physical hard drives, logical (partitioned) drives, and virtual or temporary drives.
  • Size The size of the filesystem.
  • Used – Amount of space used on each filesystem.
  • Avail – The amount of unused (free) space on the filesystem.
  • Use% – Shows the percent of the disk used.
  • Mounted on – This is the directory where the file system is located. This is also sometimes called a mount point.

The list of filesystems includes your physical hard drive, as well as virtual hard drives:

  • /dev/sda2 – This is your physical hard drive. It may be listed as /sda1, /sda0, or you may even have more than one. /dev stands for device.
  • udev This is a virtual directory for the /dev directory. This is part of the Linux operating system.
  • tmpfs – You may have several of these. These are used by /run and other Linux processes as temporary filesystems for running the operating system. For example, the tmpfs /run/lock is used to create lockfiles. These are the files that prevent multiple users from changing the same file at the same time.

Display a Specific File System

The df command can be used to display a specific file system:

You can also use a backslash:

This displays the usage on your primary hard drive. Use the mount point (in the Mounted on column) to specify the drive you want to check.

Note: The df command only targets a full filesystem. Even if you specify an individual directory, df will read the space of the whole drive.

Display File Systems by Type

To list all file systems by type, use the command:

This lists drives with the ext4 type, in human-readable format.

Display Size in 1000 Instead of 1024

You can display disk usage in units of 1000 instead of 1024:

This can address a point of confusion in storage technology. Hard drive manufacturers sell hard drives in sizes based on 1000 bytes = 1 kilobyte.

However, operating systems divide that space up so that 1024 bytes = 1 kilobyte. Because of this, a 1000-gigabyte hard drive ends up with roughly 930 gigabytes of usable storage.

Note: Check out our overview of the Linux free command used to check total, used, shared, free, and available memory and swap space.

Check Disk Space in Linux With du Command

The du command displays disk usage. This tool can display disk usage for individual directories in Linux, giving you a finer-grained view of your disk usage. Use it to display the amount of space used by your current directory:

How to view free disk space and disk usage from the linux terminal

Like the df command, you can make du human-readable:

It displays a list of the contents of the current directory, and how much space they’re using. You can simplify the display with the -s option:

This shows how much space the current directory uses.

To specify the directory or file, check use the following options:

With the second command, you may have noticed a permission denied error message. This means the current user doesn’t have the privileges to access certain directories. Use the sudo command to elevate your privileges:

Note: If you’re working on CentOS Linux, you may need to use the su command to switch to the root user to access protected directories.

You should now understand how to use df and du commands to check disk space on your Linux system. Remember, to display a complete list of options, use either df –help or du –help .

Check out our article on how to use fsck command to run a filesystem check as preventive maintenance or when there is an issue with your system.

This is a classic article written by Jack Wallen from the Linux.com archives. For more great SysAdmin tips and techniques check out our free intro to Linux course.

Quick question: How much space do you have left on your drives? A little or a lot? Follow up question: Do you know how to find out? If you happen to use a GUI desktop (e.g., GNOME, KDE, Mate, Pantheon, etc.), the task is probably pretty simple. But what if you’re looking at a headless server, with no GUI? Do you need to install tools for the task? The answer is a resounding no. All the necessary bits are already in place to help you find out exactly how much space remains on your drives. In fact, you have two very easy-to-use options at the ready.

In this article, I’ll demonstrate these tools. I’ll be using Elementary OS, which also includes a GUI option, but we’re going to limit ourselves to the command line. The good news is these command-line tools are readily available for every Linux distribution. On my testing system, there are a number of attached drives (both internal and external). The commands used are agnostic to where a drive is plugged in; they only care that the drive is mounted and visible to the operating system.

With that said, let’s take a look at the tools.

The df command is the tool I first used to discover drive space on Linux, way back in the 1990s. It’s very simple in both usage and reporting. To this day, df is my go-to command for this task. This command has a few switches but, for basic reporting, you really only need one. That command is df -H. The -H switch is for human-readable format. The output of df -H will report how much space is used, available, percentage used, and the mount point of every disk attached to your system (Figure 1).

How to view free disk space and disk usage from the linux terminalFigure 1: The output of df -H on my Elementary OS system.

What if your list of drives is exceedingly long and you just want to view the space used on a single drive? With df, that is possible. Let’s take a look at how much space has been used up on our primary drive, located at /dev/sda1. To do that, issue the command:

The output will be limited to that one drive (Figure 2).

How to view free disk space and disk usage from the linux terminalFigure 2: How much space is on one particular drive?

You can also limit the reported fields shown in the df output. Available fields are:

source — the file system source

size — total number of blocks

used — spaced used on a drive

avail — space available on a drive

pcent — percent of used space, divided by total size

target — mount point of a drive

Let’s display the output of all our drives, showing only the size, used, and avail (or availability) fields. The command for this would be:

The output of this command is quite easy to read (Figure 3).

How to view free disk space and disk usage from the linux terminalFigure 3: Specifying what output to display for our drives.

The only caveat here is that we don’t know the source of the output, so we’d want to include source like so:

Now the output makes more sense (Figure 4).

How to view free disk space and disk usage from the linux terminalFigure 4: We now know the source of our disk usage.

Our next command is du. As you might expect, that stands for disk usage. The du command is quite different to the df command, in that it reports on directories and not drives. Because of this, you’ll want to know the names of directories to be checked. Let’s say I have a directory containing virtual machine files on my machine. That directory is /media/jack/HALEY/VIRTUALBOX. If I want to find out how much space is used by that particular directory, I’d issue the command:

The output of the above command will display the size of every file in the directory (Figure 5).

How to view free disk space and disk usage from the linux terminalFigure 5: The output of the du command on a specific directory.

So far, this command isn’t all that helpful. What if we want to know the total usage of a particular directory? Fortunately, du can handle that task. On the same directory, the command would be:

Now we know how much total space the files are using up in that directory (Figure 6).

How to view free disk space and disk usage from the linux terminalFigure 6: My virtual machine files are using 559GB of space.

You can also use this command to see how much space is being used on all child directories of a parent, like so:

The output of this command (Figure 7) is a good way to find out what subdirectories are hogging up space on a drive.

How to view free disk space and disk usage from the linux terminalFigure 7: How much space are my subdirectories using?

The du command is also a great tool to use in order to see a list of directories that are using the most disk space on your system. The way to do this is by piping the output of du to two other commands: sort and head. The command to find out the top 10 directories eating space on a drive would look something like this:

The output would list out those directories, from largest to least offender (Figure 8).

How to view free disk space and disk usage from the linux terminalFigure 8: Our top ten directories using up space on a drive.

Not as hard as you thought

Finding out how much space is being used on your Linux-attached drives is quite simple. As long as your drives are mounted to the Linux system, both df and du will do an outstanding job of reporting the necessary information. With df you can quickly see an overview of how much space is used on a disk and with du you can discover how much space is being used by specific directories. These two tools in combination should be considered must-know for every Linux administrator.

And, in case you missed it, I recently showed how to determine your memory usage on Linux. Together, these tips will go a long way toward helping you successfully manage your Linux servers.

How to view free disk space and disk usage from the linux terminal

Anthony Heddings
How to view free disk space and disk usage from the linux terminalAnthony Heddings
Writer

Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon’s AWS platform. He’s written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read more.

How to view free disk space and disk usage from the linux terminal

While it’s usually pretty clear if your system is running out of memory or using too much CPU time, disk usage is another key metric that can sneak up on you over time if you leave your server unattended. You’ll want to regular check your disk usage using these commands.

Checking Disk Usage On Linux

The utility used to quickly check disk usage on almost all Linux systems is df , which stands for “disk filesystems.” It simply prints out a list of all the filesystems on your system.

This command here is invoked with two flags, -h for “human readable,” which prints out byte numbers in KB, MB, and GB, and -T , which displays the type of the filesystem.

df will print out each filesystem alongside the size, how much is used and available, and where it’s mounted to on your system.

How to view free disk space and disk usage from the linux terminal

You’ll quickly notice that you probably have a lot more “filesystems” than you’d expect. This server only has one solid state drive, but has over 20 filesystems. Most of these are backend stuff used for other programs and services, such as compressed squashfs , virtual tmpfs , and Docker’s overlay systems used for containers.

In this example, ext4 is the real drive, which is obvious because it’s mounted at root, but in multi-drive systems that may not be immediately clear. If you want, you can filter this list by specifying which type you want to see with the lowercase -t flag:

How to view free disk space and disk usage from the linux terminal

Or by removing what you don’t want to see manually with the -x flag:

How to view free disk space and disk usage from the linux terminal

You can also ask df for info on any specific filesystem, even including wildcards to match multiple systems by name:

Or, you can ask it for info on a specific mount, which is most useful for quickly getting the info on your root system:

Monitoring At a Glance

Most of the time though, you probably don’t want to remember and type a bunch of commands with specific flags. That’s what the glances utility was made for, and we highly recommend giving it a try.

It’s basically a replacement for built-in utilities like top and htop , except it displays a lot of different performance metrics about your system, the disks. It’s not included in most Linux distros by default, but it’s open source and can be installed from pip , given it’s a Python app.

Then simply run the app to open up the glances dashboard:

How to view free disk space and disk usage from the linux terminal

You’ll find in the lower left corner some info on disk usage, including current I/O speeds, as well as each physical disk’s total usage. Using this, you can easily spot problems with disks filling up before it breaks your system.

How to view free disk space and disk usage from the linux terminal

There are plenty of other utilities for monitoring your system, but glances checks all the boxes, so it’s a pretty nice tool to have.

Sending Alerts When Your Disk Usage Is Too High

The main problem with command line tools is that they require you to be proactive about checking for problems. But problems can pop up unexpectedly, so it’s good to get notified about them beforehand.

So, the solution is to set up a daily cron job that will run df automatically to check the usage on the root system. It will compare this with a set value, and if it’s greater, it’ll send a message.

You have plenty of options for how to get messages, and it will depend on your preferred contact. The simplest would be to set up the mail utility to send you emails from the command line. You can read our article on setting up Postfix to handle this for you.

A much cooler method is to send yourself a message directly on a messaging platform you’re active on, such as setting up Slack notifications from your server, which can be easily done using webhooks with curl POST requests.

How to view free disk space and disk usage from the linux terminal

  • › How to Deploy a GitLab Server With Docker
  • › What’s Coming In React 18?
  • › How to Deploy a Caddy Web Server With Docker
  • › How to Use Docker to Package CLI Applications
  • › CloudFoundry vs Kubernetes: Which Cloud Platform Should You Choose?
  • › What’s New In TypeScript 4.6?

How to view free disk space and disk usage from the linux terminal

Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon’s AWS platform. He’s written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read Full Bio »

I am writing an installer in bash. The user will go to the target directory and runs the install script, so the first action should be to check that there is enough space. I know that df will report all file systems, but I was wondering if there was a way to get the free space just for the partition that the target directory is on.

Edit – the answer I came up with

Slightly odd because df seems to format its output to fit the terminal, so with a long mount point name the output is shifted down a line

7 Answers 7

for the current directory.

if you want to check a specific directory.

You might also want to check out the stat(1) command if your system has it. You can specify output formats to make it easier for your script to parse. Here’s a little example:

How to view free disk space and disk usage from the linux terminal

  1. df command : Report file system disk space usage
  2. du command : Estimate file space usage

Type df -h or df -k to list free disk space:

du shows how much space one or more files or directories is using:

The -s option summarizes the space a directory is using and -h option provides Human-readable output.

How to view free disk space and disk usage from the linux terminal

I think this should be a comment or an edit to ThinkingMedia’s answer on this very question (Check free disk space for current partition in bash), but I am not allowed to comment (not enough rep) and my edit has been rejected (reason: “this should be a comment or an answer”). So please, powers of the SO universe, don’t damn me for repeating and fixing someone else’s “answer”. But someone on the internet was wrong!™ and they wouldn’t let me fix it.

has a substantial flaw: Yes, it will output 50G free as 50 — but it will also output 5.0M free as 50 or 3.4G free as 34 or 15K free as 15.

To create a script with the purpose of checking for a certain amount of free disk space you have to know the unit you’re checking against. Remove it (as sed does in the example above) the numbers don’t make sense anymore.

If you actually want it to work, you will have to do something like:

Also for an installer to df -k $INSTALL_TARGET_DIRECTORY might make more sense than df -k “$PWD” . Finally, please note that the –output flag is not available in every version of df / linux.

Like every other operating system, Linux also provides multiple ways to keep track of the disk space on your device, including both CLI-based and GUI-based methods. In Linux, however, most operations are performed via the command line. Therefore, Linux users are more likely to be interested in methods of checking disk space via the command line. This is why our discussion today will revolve solely around methods for checking disk space in Linux from the command line.

Note: All the methods shown below have been tested in Linux Mint 20.

Checking the Disk Space in Linux from the Command Line

There are multiple ways to check the disk space in Linux; however, the most effective ones involving the command line interface have been presented below.

Method 1: Using the df Command

The df command stands for Disk Filesystem, and it is a built-in utility in the different flavors of the Linux operating system. The df command is used to monitor disk space utilization, as well as the total available space. To check the disk space using this utility, proceed as follows:

First, launch the terminal in Linux Mint 20 by clicking on its desktop icon, shown in the image below:

After launching the terminal in Linux Mint 20, execute the following command in the terminal:

Running this command will display the total space of the whole file system, the total amount of used space, as well as the available space, along with some other information, as shown in the following image:

How to view free disk space and disk usage from the linux terminal

Method 2: Using the df command with the -a Flag

The df command can also be used in conjunction with the -a flag, which is used to display the disk space of all the file systems (i.e., your actual file system and also the dummy ones). Perform the steps shown below to use the df command with the -a flag:

Launch the terminal in Linux Mint 20 and execute the command shown below:

The output of this command will be quite large, and you will have to scroll through your terminal to view the entire output. This is because the -a flag does not only print the disk space of a single file system; rather, it does so for all available file systems.

How to view free disk space and disk usage from the linux terminal

Method 3: Using the df command with the -h Flag:

Certain technical terms may not be easily understandable by a new user. For example, in the outputs of both the methods discussed above, you can see a column named “1K-blocks.” This column represents the total number of “1K-blocks” present in each file system. In other words, this is the size of the file system in bytes, which can be difficult to interpret and memorize. Basically, it is a technical way of representing the size of each file system, but this is not so intuitive for a layman. Therefore, the -h flag can be used with the df command to display the disk space in a more human-readable format. To make this happen, follow the steps provided below:

Launch the Linux Mint 20 terminal as explained above, and then execute the following command:

Running this command will display the disk space of your file system in a way that you will easily be able to interpret, i.e., the disk space will be displayed in megabytes (MBs), gigabytes (GBs), etc. You can see this output in the image below:

How to view free disk space and disk usage from the linux terminal

In the same manner, you can also use the -k and -m flags with the df command to check the disk space in Linux via the command line in kilobytes and megabytes, respectively. This can be done if you require the disk space in a specific unit for a specific purpose. By allowing this, the df command or utility provides you with the flexibility to check your disk space in whichever format you prefer.

Conclusion

This article showed you how to check the available disk space in a device using the command-line in Linux. All the three methods described above were a variation of the df command. You can easily use the df command to check the disk space in Linux from the command line by adjusting the flags according to your requirements. Or, you can simply use this command alone and without any flags. The output of this command will help you to see your current disk space usage and the amount of free space.

Apart from the use cases of the df command discussed in this article, this command can also be used to check the disk space of a specific file system; to know the total, available, and used inodes of a file system; to check the type of each file system; to filter out the file systems based on a particular type; and much more. However, all of these use cases are beyond the scope of this article. That is why we have only focused on the use cases of the df command that are directed towards checking the disk space.

About the author

How to view free disk space and disk usage from the linux terminal

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.

How to view free disk space and disk usage from the linux terminal

In this tutorial, we are going to show you how to use the df command to check disk space, and the du command to monitor disk usage in terminal. These are the two essential Linux commands that will help you manage your files more effectively.

Analyzing the Hard Drive

df and du commands have a slightly different purpose when analyzing a hard drive. In order to avoid confusion, we’ll explain them in separate sections. Let’s begin with the df command!

Check Disk Space in Linux Using the df Command

df, which stands for Disk Filesystem, is used to check disk space. It will display available and used storage of file systems on your machine.

When executing this command, you will see the default columns: Filesystem, Size, Used, Available, Use%, and Mounted On. It should look something like this:

  • FileSystem — provides the name of the file system.
  • Size — gives us the total size of the specific file system.
  • Used — shows how much disk space is used in the particular file system.
  • Available — shows how much space is left in the file system.
  • Use% — displays the percentage of disk space that is used.
  • Mounted On — tells us the mount point of a particular file system.

By adding a certain option to the df command, you can check the disk space in Linux more precisely. These are the most popular options:

  • df -h — it will display the result in a human-readable format.
  • df -m — this command line is used to display information of file system usage in MB.
  • df -k — to display file system usage in KB.
  • df -T — this option will show the file system type (a new column will appear).
  • df -ht /home — it allows you to view information about a specific file system in a readable format (in this case /home file system).
  • df — help — it lists down other useful options that you can use, complete with their descriptions.

Check Disk Usage in Linux Using the du Command

Another important command is du, short for Disk Usage. It will show you details about the disk usage of files and directories on a Linux computer or server. With the du command, you need to specify which folder or file you want to check. The syntax is as follow:

Let’s take a look at real-world use of the du command with the Desktop directory:

  • du /home/user/Desktop — this command line allows users to see into the disk usage of their Desktop folders and files (subdirectories are included as well).
  • du -h /home/user/Desktop — just like with df, the option -h displays information in a human-readable format.
  • du -sh /home/user/Desktop — the -s option will give us the total size of a specified folder (Desktop in this case).
  • du -m /home/user/Desktop — the -m option provides us with folder and file sizes in Megabytes (we can use -k to see the information in Kilobytes).
  • du -h — time /home/user/Desktop — this informs the last modification date of the displayed folders and files.
  • df –help — it displays a list of available options and what they can be used for.

Combining Commands and Cleaning Disk Space

You can get more information done by combining df and du command with other arguments. By doing this, you will get a better idea of which files you can delete to free up disk space.

Just remember to start with df command to see which file system needs a cleanup the most. After that, you can proceed with these combinations.

Sorting Files By Size

First, we gather files and folders on the Desktop in a readable format using the du command. Then, we pipe the result to the sort command together with the -rn option. The script will sort all the files and folders from largest to smallest to check the disk space use in Linux. The combination should look like this:

Remember that you shouldn’t necessarily delete files just because they are large. If you’re not cautious, you might delete essential files that would break your project.

Excluding by File Size

Let’s say you want to see all files that are above a certain size. The most effective way to do that is by using the command below:

The grep command allows us to search for files based on a specified pattern. In this example, the script will return with any files bigger than 1 GB. If you want to single out 1 MB+ data, you can replace G with M.

Excluding File Types

The last combination is useful when you need to exclude a particular file format from the search results. For instance:

The –exclude=”.txt” argument makes sure the du command will display all file formats except for .txt documents.

Conclusion

df and du commands are file management tools that will check disk space in Linux and display all stored files on your machine. You are allowed to add certain options (like -h, -m, -k, etc.) to refine the output based on your needs.

What’s great, users can get a more specific result by combining du and df with other commands, such as sort, grep, and exclude. Together, they will help you better understand how disk space is used on your server. Be sure to check out our article for more useful Linux commands.

If you have any questions, feel free to comment down below!

Discover Other Linux Commands for Server Management

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.

Use code KB4KDO0L9 to receive a 10% recurring discount on any server.

How to view free disk space and disk usage from the linux terminal

When managing your servers, taking charge of system resources is of utmost importance. There are many advantages and benefits of Linux which makes it one of the most popular operating systems out there. Every server has a lot of resources like memory, computing power, etc. One of the most important system resources is the hard disk space. To manage your server effectively and ensure no unwanted disruption, you need to manage your disk space frequently. When your system runs out of space, the application or database hosted on the system will crash. Recovery from a crash might take some time, and you may lose important data which wasn’t flushed to disk because the disk ran out of space. You can learn about ServerMania’s Linux dedicated servers and Linux server costs on our official blog.

The Linux ecosystem provides you with the df (which stands for disk free) command to find disk space utilization information from the command line. Of course, in the Linux-based GUI operating systems like Ubuntu, you can get the disk space available from the GUI (using the Disk Usage Analyzer tool) and the command line.

The barebones version of the df command will show you the space occupied by different drives in 1KB (kilobyte) blocks. In the output, you will be provided with mount point information, available and used space, and the percentage occupancy of the disk. To check disk space for all the filesystems and their disk usage, you need to log into your Linux terminal and type the following command:

Check Disk Space in Linux using the command df (disk free)

You can use many options with the df command to check disk space:

Let’s look at some important ones.

Disk Space in Human Readable Format

The first difficultly one faces while reading disk space from the df command is that the disk space, by default, is presented in bytes. To get this data in a human-readable format, i.e., in KB, MB, GB, and TBs, use -h (for powers of 1024) or -H (for powers of 1000) options as shown below:

Summary with Total Available and Total Used Disk Space

Sometimes it is handy to have the total available and total used disk space for reporting and alerting purposes. Rather than running this command directly from the CLI on your operating system, you can also get this data using an alerting service like Nagios or DataDog.

Disk Space with the Filesystem Type

This command helps you fetch the filesystem type, along with the usual information offered by the df command:

Disk Space in Inodes Instead of 1K Blocks

If you have an application that generates a lot of tiny files and stores them locally on disk, in addition to the disk space, you might want to track the Inode usage with the following command:

Disk Space for a Given Filesystem

The following command shows you the usage for a given directory and the available space and percentage usage on the filesystem this directory is mounted on:

Check Disk Usage in Linux using du (disk usage) Command

While the df command helps you get a summary of available and occupied disk space for all the file systems on your Linux system, the du command concentrates only on occupied space. The du command stands for disk usage. A basic example of the usage of the du command is shown below:

Disk Usage in Human Readable Format

Similar to df -h, here’s the du -h command:

Disk Usage for Current Working Directory along with the Total Usage

The -c option adds a total at the end of the usage summary as shown in the result below:

Disk Usage for All Files, Directories, and Subdirectories

This command will fetch the file and directory sizes of all the files, directories, and subdirectories. Be careful while using this on systems that have a very large number of files. This command is useful but when used in combination with grep or sort.

Disk Usage after Excluding Certain Types of Files

If you want to exclude hidden files, add the –exclude “./.*” option to the du command:

Disk Usage with the Largest File or Directory First

One of the main reasons for checking disk usage is to clear up space occupied by redundant or unnecessary files. You can run the following command to check disk space based on the largest files first:

These are some of the most commonly used commands for checking disk usage and disk space in Linux.

Learn how to check hard disk size in Ubuntu terminal. 5 useful commands to check hard disk space via Ubuntu command line. On Ubuntu, check disk space in GB using any of these commands.

Before we begin, let use see the GUI way to check disk space in Linux Ubuntu:

Check how much disk space is left on Ubuntu

You can check how much disk space is left with Disk Usage Analyzer or System Monitor.

Check with Disk Usage Analyzer

To check the free disk space and disk capacity using Disk Usage Analyzer:

  • Open Disk Usage Analyzer from the Activities overview. The window will display a list of file locations together with the usage and capacity of each.
  • Click one of the items in the list to view a detailed summary of the usage for that item. Click the menu button, and then Scan Folder… or Scan Remote Folder… to scan a different location.

The information is displayed according to Folder, Size, Contents and when the data was last Modified.

Check with System Monitor

To check the free disk space and disk capacity with System Monitor:

  1. Open the System Monitor application from the Activities overview.
  2. Select the File Systems tab to view the system’s partitions and disk space usage. The information is displayed according to Total, Free, Available and Used.

Check Disk Space In Ubuntu Terminal

The “df” command is for “disk filesystem” and is a great tool to know about the disk space usage on Linux Systems. The df command displays the amount of disk space available on the file system.

If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system).

How to view free disk space and disk usage from the linux terminal

Example-1:

The simplest df command is by itself. Without any command parameters. When executed the df command displays the information about the file system disk space usage. It shows the device name, total blocks, total disk space, used disk space, free disk space and mount points.
df

Example-2:

Using the df command with -a or –all it shows dummy file systems information along with all the basic file system disk usage info:
df -a

Example-3:

As the disk space is shown in 1K blocks by default, users can use “-h” command parameter to show the file system disk space usage data in “human readable” format.
df -h

Example-4:

Use the command parameters -hT to display the info about the /home file system:
df -hT /home

Example-5:

Use the command argument -k to display all file system information in 1024-byte blocks:
df -k

Example-6:

Similarly you can use the command argument -m to display all file system information in MB (Mega Byte) and -h to see the info in GB (Gigabyte):
df -m
df -h

Example-7:

If you wish to see the disk space usage info of a certain file system type, use it as argument:
df -t ext3

Similarly there are many more command arguments that can be used to see the desired info.

In CentOS and Ubuntu, how do I find out how much free disk space I have left and other disk stats like disk usage?

How to view free disk space and disk usage from the linux terminal

How to view free disk space and disk usage from the linux terminal

4 Answers 4

Type the following command:

  • df : disk free
  • -h : makes the output human-readable

How to view free disk space and disk usage from the linux terminal

It’s ncurses based, feature rich and has a nice clean interface and it works from within a shell.

How to view free disk space and disk usage from the linux terminal

  • display diskspace used by files & directories within a directory
  • display what’s happened since the last ran (see screenshots below)
  • optionally provides links to the files, so you can also browse them
  • displays entries with their size & the percentage of their parent
  • ommits small files/directories
  • easy browsing using the cursor-keys
  • produces html files for browsing ‘offline’ afterwards

How to view free disk space and disk usage from the linux terminal

Disk Usage Analyzer (aka. Baobab)

  • Single folder scan
  • Remote scan
  • Monitoring of Home
  • Display Data in Treemaps or as Ringschart

How to view free disk space and disk usage from the linux terminal

others.

In particular fsview is a very nice GUI. I like how it organizes the disk usage visually. It’s actually a KDE application (a plugin to Konqueror) but runs just fine under GNOME. It’s typically part of a package called kdeaddons, and shows up in the Applications menu as “File System Viewer” under Accessories.

You can check how much disk space is left with Disk Usage Analyzer , System Monitor , or Usage .

Check with Disk Usage Analyzer

To check the free disk space and disk capacity using Disk Usage Analyzer :

Open Disk Usage Analyzer from the Activities overview. The window will display a list of file locations together with the usage and capacity of each.

Click one of the items in the list to view a detailed summary of the usage for that item. Click the menu button, and then Scan Folder… to scan a different location.

The information is displayed according to Folder , Size , Contents and when the data was last Modified . See more details in Disk Usage Analyzer .

Check with System Monitor

To check the free disk space and disk capacity with System Monitor :

Open the System Monitor application from the Activities overview.

Select the File Systems tab to view the system’s partitions and disk space usage. The information is displayed according to Total , Free , Available and Used .

Check with Usage

To check the free disk space and disk capacity with Usage :

Open the Usage application from the Activities overview.

Select Storage tab to view the system’s total Used and Available disk space, as well as the used by the Operating System and common user’s directories.

Disk space can be freed from user’s directories and its subdirectories by checking the box next to the directory name.

What if the disk is too full?

If the disk is too full you should:

Delete files that aren’t important or that you won’t use anymore.

Make backups of the important files that you won’t need for a while and delete them from the hard drive.

More Information

  • Disks & storage — Check on disk space and control how disk space is allocated and used.

You can choose the displayed language by adding a language suffix to the web address so it ends with e.g. .html.en or .html.de.
If the web address has no language suffix, the preferred language specified in your web browser’s settings is used. For your convenience:
[ Change to English Language | Change to Browser’s Preferred Language ]

The material in this document is available under a free license, see Legal for details.
For information on contributing see the Ubuntu Documentation Team wiki page. To report errors in this documentation, file a bug.

Learn one of the quickest ways to free up disk space in Linux.

How to view free disk space and disk usage from the linux terminal

If you’re new to the world of Linux, you may find yourself wondering how to free up disk space. It’s not always as simple as just uninstalling some programs. This is particularly true if you have many files taking up space scattered across your whole filesystem. While there are many different ways to free up disk space in Linux, read on to learn about one of the quickest: using du and some basic terminal commands.

What is du?

du is a standard command in Linux that quickly shows information on disk usage. The name of the command itself stands for “disk usage.” While this may seem very basic, du has a whole host of options and uses that make it a valuable tool for both beginners and advanced Linux users.

How to Start Using du

You may be wondering how to start using du . The simplest and most basic way is, of course, using the command as is without any options:

How to view free disk space and disk usage from the linux terminal

However, this isn’t particularly useful information. The output given here is often used by other programs and scripts, but to make it useful for the average user, we will need to include some options.

One such option is to convert the size outputs to a format you can read. To do this, you will need to add either the -h flag or the –human-readable flag.

How to view free disk space and disk usage from the linux terminal

This makes the size of the files on the left much easier to parse. But there’s still a lot to sort through here. Luckily, some other options make this easier.

The -s flag will summarize the given directory’s disk usage. This is often combined with the -h flag to give a very simple and easy-to-read summary of the directory.

How to view free disk space and disk usage from the linux terminal

Depending on which directories you’re checking with du , you may need to elevate your privileges using sudo or similar. For example: when you want to see how much disk usage the root directory is using.

While there are many other useful options you can use with du , the -h and -s flags are the only ones we need in order to clean up disk space.

How to Free Up Linux Disk Space with du

Now that you know how to use du , you can make use of it when freeing up disk space on your computer.

The quickest way to clean up your disk is to first find out what is using the most space. You can do this by letting du scan the entire system. To do this, you will add an asterisk to the end of the directory path. The asterisk works as a wildcard and tells the command to look at everything in the directory.

How to view free disk space and disk usage from the linux terminal

This shows you which directory in the filesystem is occupying the most space. From there, you can use the same command in each directory to find out which sub-directories and files are taking up the most space.

In many cases, you will be searching your home directory, as this is where you will store your personal files. You can do this by searching

/ , as this is shorthand for your home directory.

How to view free disk space and disk usage from the linux terminal

Continue to repeat these commands as much as needed to narrow down which directories are taking up the most space.

For example, if you have a directory called “Storage” in your home folder taking up a lot of space, use du to figure out which files in it are the biggest.

How to view free disk space and disk usage from the linux terminal

From here, you can simply delete the files you don’t want to use the rm command.

Do this for every other file you no longer want on your drive to free up the desired amount of storage space.

Frequently Asked Questions

1. Is there a way to sort by file size?

Yes, you can pipe the output from du into sort in order to sort by file size.

2. How do I see how much free disk space I have?

You would use df , a completely different command with a very simple usage, to see how much free disk space you have:

3. Should I use du to remove programs from my computer?

No, this method is only useful for files you’ve saved yourself. If you want to remove a program, you should use your distribution’s package manager or software center.

Wrapping Up

As you can see, freeing up disk space in Linux using the command line is quite simple. Once you have the hang of using du and all its options, you’ll find that it’s also much quicker and easier than most other methods.

But this is just the tip of the iceberg when it comes to commands. Read on to find out which commands to use to search for files in Linux.

Displaying Disk Space Statistics (df)

Use the df command to show the amount of free disk space on each mounted disk. The usable disk space that is reported by df reflects only 90 percent of full capacity, as the reporting statistics allows for 10 percent above the total available space. This head room normally stays empty for better performance.

The percentage of disk space actually reported by the df command is used space divided by usable space.

If the file system exceeds 90 percent capacity, you could transfer files to a disk that is not as full by using the cp command. Alternately, you could transfer files to a tape by using the tar or cpio commands. Or, you could remove the files.

For a detailed description of this command, see the df(1M) man page.

If you’ve ever ran out of disk space, you know how terribly painful it can be. Applications will stop opening, indexing services crawl. If you have a swap file or partition configured, it will start to shred. Working with a remote server can be even more painful, especially if you don’t have any GUI monitoring services running. Fortunately, we can get everything we need from the command-line using commands like df and du .

Getting Started

This article will use the commands df and du to analyze disk and partitiona space as well as storage usage by files and directories. These commands are pretty standard on Unix-like operating systems like macOS and Linux.

Neither command requires elevated privileges, unless you are attempting to use du on a directory that you don’t have permission to. We’ll be working with files and directories that your user account should have access to and none of the commands are destructive in nature.

Disk Free

The df command allows you to get information about the physical disks and partitions of the system you are on. Running the command without any arguments will present you with a list of the disks, their total size, storage used and available, and the mount point on your system:

Will output something like this:

The output on your system may look a bit different as there are different implementations of the df command. The output above is from the GNU version of df .

The numbers can be a bit intimidating as they can be pretty large and aren’t prettified up with commas or periods. To improve the output, we can add the -h or –human-readable flag to display the sizes in the power of 1024:

Which changes the output to:

There is also the -H or –si that will use the powers of 1000 instead of 1024.

Because I’m a human, and prefer to save a few keystrokes whenever possible, I alias df to df -h in my shell configuration:

If you’re working with a system that has a ton of directories or files, the inode (or index node) usage may be more important than the block size. If you would prefer to see the inode usage information, you can pass the -i or –inodes argument:

Which presents a similar set of information, but with inode information instead of block storage information:

And assuming you’re a human, you can also include the -h argument to display the inode information in a more human-readable format.

Disk Usage

The du command allows you to see the disk usage information at a more micro level than that of the df command. Invoking the du command without any arguments will display the disk usage for the current directory.

If you would prefer to show the disk usage for a directory that isn’t the directory you’re current in, you can simply pass in the path:

If you were to run that command from your home directory, you’ll probably be greeted with a ton of output that quite frankly, is pretty intimidating and hard to sift though.

Some truncated results from my own system:

The command lists out every single directory, subdirectory and file and reports the amount of disk space that it’s occupying. The final line of the output is the total disk usage for the directory, at upper most level.

Similar to df , the du output defaults to the number of bytes. Both set of arguments, -h and –human-readable as as well as -H and –si are available, to help make the output more digestible:

Which outputs the information in the base of 1024:

And if you’re more interested in the inode values than the block storage values, you can also use the -i or –inodes argument.

Even with the human-readable output, a large directory is going to be pretty noisy since every single directory, subdirectory and file is going to be reported on.

To help clean up the output a bit, we can limit the depth that is output by passing in the -d or –max-depth argument:

Depending on the size of the directory, limiting the max depth to traverse may cause things to appear like they are locked up since there will be a lack of visual output.

The du command isn’t limited to a single directory either, if you wanted to find out the disk usage for your home directory as well as /tmp you can do so quite easily:

Conclusion

If you’re a macOS user and have tried to get the total size of a handful of files and/or directories from Finder, there’s a good chance you’ve wound up with a bunch of open Information dialogs.

Graphical tools can be quite convenient, but tend to fall short for power user scenarios. Generally speaking, they also tend to not be available on remote systems.

Commands like df and du don’t do much, but they do it well. Getting the size of files and disk usage tends to be a task that comes up when you’re low on space and need to get something resolved quickly.

These commands make it easy to identify problem areas in your system quick and efficiently and are generally available on Linux systems out of the box.

du and df commands are great for fetching disk usage from the Terminal.

How to view free disk space and disk usage from the linux terminal

T here are several ways of checking your Linux system disk space. You could use a third-party app that shows the available disk space or do it by command-line way via the Linux Terminal.

In this guide, we are going to show you the best command-line ways of finding the disk space alongside some tips and tricks.

You can check disk space using du and df commands. Let’s discuss each of these commands with examples.

Method 1: Checking the disk space using du command

The du command in Linux is a short cut for Disk Usage. Using the du command, you can check your directories disk usage.

Syntax:

Example 1. Find out disk usage on a specific directory and display the disk size in a human-readable format.

Example 2. Check disk usage and sort by top 5 directories that are using most disk space.

Method 2: Checking disk usage via the df command

The df is another powerful command you can use for fetching the disk space summary in a variety of ways.

Syntax:

Example 1. Display the Linux disk space usage for the file system.

Example 2. The df command has several options that you can use to determine your Linux file system disk usage. Use the following command to display the df command help.

Example 3. Display all the information for the disk space usage on all the file systems.

Example 4. Display the disk space usage for the file system in a human-readable format.

Example 5. To fetch the data just for the home file system only, use the following command:

Example 6. Check disk space usage for all drivers and show specific columns.

Example 7. Display the disk space usage for the file system in bytes.

Example 8. The same thing, but in megabytes.

Example 9. Display disk space usage for the file system alongside its type.

I hope you enjoyed this tutorial in figuring out du and df command usage scenarios. To see all the available df command options, you can use man df or man du in your terminal.

There are numerous ways of checking Linux system disk space. A third-party app that shows the available disk space or by command-line way via the Linux Terminal two of which are df and du, where du is disk space used and df is disk space free.

1. Using du Command

Using du command for checking disk space. du stands for “Disk Usage”, using this command we can check directories disk usage.

Syntax:

For help, we can use

How to view free disk space and disk usage from the linux terminal

For checking disk usage on a particular directory and display there size in a human-readable format.

How to view free disk space and disk usage from the linux terminal

For checking disk usage, and sort by first 3 directories that are using most maximum disk space.

How to view free disk space and disk usage from the linux terminal

2. Using df Command

Using df command for checking disk usage. df is an abbreviation for “disk free”, it displays the amount of available disk space for file systems.

Syntax:

Showing disk space usage for the file system

How to view free disk space and disk usage from the linux terminal

To show all the information for the disk space usage on all the file system “-a” is used.

How to view free disk space and disk usage from the linux terminal

To show disk space usage of the file system for human “-h” is used.

How to view free disk space and disk usage from the linux terminal

To fetch the data just for the single directory.

To see disk space usage and display specific columns.

How to view free disk space and disk usage from the linux terminal

Display the disk space usage for the file system in bytes we will use “-k” and to display it in megabytes we will use “-m”.

Here is a quick overview of 5 command-line tools that come in incredibly handy when troubleshooting or monitoring real-time disk activity in Linux. These tools are available in all major Linux distros.

iostat

iostat can be used to report the disk read/write rates and counts for an interval continuously. It collects disk statistics, waits for the given amount of time, collects them again and displays the difference. Here is the output of the command iostat -y 5 :

Each report, every 5 seconds, include the CPU stats and the disk stats. The CPU stats is a break up of where CPU time was spent during the interval. The disk stats includes the number of I/O requests per second ( tps ), the rate of read and write ( kB_read/s and kB_write/s ) and the amount of data read and written ( kB_read and kB_wrtn ).

The -y argument instructs iostat to discard the first report which are the stats since boot and are rarely useful. The “5” in the command line specifies the interval in seconds. The CPU stats can be omitted by including the -d flag, although practically it is useful to have it there.

iotop

iotop is a top-like utility for displaying real-time disk activity. It can list the processes that are performing I/O, alongwith the disk bandwidth they are using. Here is how iotop -o looks like:

The -o flag restricts the display to processes that are doing I/O, omitting it shows all the processes. You can also see the total disk bandwidth usage on the top two lines.

In case you are wondering, the “total” values show the amount of data read from or written to the disk block device driver, and the “actual” values show the numbers for the actual hardware disk I/O. File system caching is one of the reasons for the difference in the values.

dstat

dstat is a little more user-friendly version of iostat , and can show much more information than just disk bandwidth. Here is dstat in action, showing cpu and disk stats:

As you can see, it has nicely colored output. The command-line flags include -c for CPU stats, -d for disk stats, –disk-util for disk utilization and –disk-tps for disk transactions (I/O requests) per second. You can read more about dstat here.

atop is particularly good for quickly grasping changes happening to the system. It does an excellent job of summarizing changes in each interval. Unlike the others, it can list all the processes that caused any system-level changes (like doing disk I/O) during the interval – this feature is present only in atop .

Here we’re running atop with an interval of 1 second. The top section should be read from left to right: PRC shows process information, CPU the split of CPU usage, CPL the load averages, MEM the memory usage, SWP the swap file usage and DSK and NET the disk and network information respectively. The bottom section shows processes that did interesting things during the interval. You can read more about atop here.

ioping

ioping is a quick and dirty storage volume latency checker. It is useful for checking if the elevated disk times that you’re seeing are because of a degradation of the underlying virtual disk / network / hardware.

Low numbers (<1ms) and low variance in the numbers are indicators of a healthy storage volume.

Closing Notes

All the tools listed above have more features and options, here are good places to start digging further: iostat, iotop, dstat, atop and ioping.

If you’re interested in measuring disk performance, you should definitely also look at fio and sysbench. Both are fairly complicated, but are standard tools for the job.

New Here?

OpsDash is a server monitoring, service monitoring, database monitoring and application metrics monitoring solution for monitoring MySQL, PostgreSQL, MongoDB, Memcache, Redis, Apache, Nginx, Elasticsearch and more. It provides intelligent, customizable dashboards and spam-free alerting via email, HipChat, Slack, OpsGenie, PagerDuty and Webhooks. Send in your custom metrics with StatsD and Graphite interfaces built into the OpsDash Smart Agent.

vizex can be installed through your terminal and requires Python >= 3.9 and the pip package manager . Here’s how to set up Python on your machine.

If you don’t have PyPackage Index (PyPI or just pip ) installed, Here’s the guide on how to install it. Install vizex with the following command:

If you already have vizex install you’ll need to upgrade it:

If you encounter any problems during installation, know that some vizex dependencies require a Python 3 development package on Linux and you need to set up that manually.

For Debian and other derived systems (Ubuntu, Mint, Kali, etc.) you can install this with the following command:

For Red Hat derived systems (Fedora, RHEL, CentOS, etc.) you can install this with the following command:

vizex is available as a package on the AUR (Arch user repository), distributions with AUR support may install directly from the command line using their favorite pacman helper.

Example using yay :

After installing you can use two terminal commands: vizex to display the disk usage/space and vizexdf , which will print the data of a current working directory with sizes, file types and last modified date.

This will graphically display disk space and usage:

you can now print tree of directory structure with the level you want. For example tree with level 1 only

By default level is set to 3 and path is a current path. But you can manually supply path, by just typing path you want to generate tree for, and using -l option to instruct how many levels of directories you want to print.

The best part is that you can modify the colors and style of the display to your preferences with the following commands. For the example above command has excluded two partitions. You can also do give the following options:

Display additional details, like fstype and mount point , for each partition:

If you are interested in visualizing a specific path run with the following command:

You can also exclude any combination of partitions/disks with multiple -X or for verbose –exclude option:

You can also save the partitions full information in csv or in json file, just by calling –save option with the full path where you want your output to be saved:

And if you are on laptop you can even call your battery information with simple argument:

For a full list of the available options please check:

You can include hidden files and folders by calling –all or -a for short and sort the output with –sort or -s for short based on name, file type, size, or date. Put it in descending order with the –desc option.

You can chain multiple options but make sure to put the -s at the end as it requires a text argument. Example:

This will print current directory data sorted by name and in descending order and will include hidden files.

Lastly, you save all the modifications by adding -l at the end of the command:

The next time you call vizex / vizexdf it will include all the options listed in the above command. If you decided to change the default calling command for vizex/vizexdf just include -l and it will be overwritten

If you want to contribute to the project you are more than welcome! But first, make sure all the tests run after you fork the project and before the pull request. First, run the access.py , that way tests folder will obtain a path to the main folder and you can run all the tests.

You can get the full set of features by calling –help option with command.

Special Thanks to the Contributors!

Follow Me on Social Media

Repo is distributed under the MIT license. Please see the LICENSE for more information.

How to check avilable free disk space drive on linux using C#.Net Core

Hi,
I have an console application which is developed with .net core 3.1.
I want to check free available disk space drive on linux.
Please help me on this.
In windows it will look like this, but i need to check on linux

1 Answer

As mentioned in the source code of DriveInfo, its parameterized structure is suitable for Windows and Unix, I am not sure whether it is suitable for Linux, you can try it.

Or you can use Process to call the terminal and pass commands like df to get a string like the following, and then process it to get the information you want.

The code is excerpted from this link: Finding available space for a directory in C# on Linux
I don’t have Linux OS, so I haven’t conducted actual tests, you can try to see if it works.

Update:

The above code gets the result of executing certain commands in Linux. If the Linux command is correct, it should be able to get the correct result.

But I don’t know much about Linux, which may require you to consult a Linux expert to obtain the appropriate Linux commands.

As for a piece of code that is applicable to both windows and Linux, I have some doubts whether it is possible.

I think it might be better to detect the current OS type first, and then execute different codes:

If the response is helpful, please click “Accept Answer” and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

How to view free disk space and disk usage from the linux terminal

The process to determine the amount of available hard drive space varies depending on what operating system you’re using. To proceed, select your operating system from the list below and follow the instructions.

Memory (RAM) and hard drive space are two completely different things. For memory, see: How to find how much RAM is installed on a computer.

Windows Vista, 7, 8, 10,and 11 users

  1. Press the Windows key + E to open File Explorer.
  2. In the File Explorer window, in the left navigation pane, click This PC.
  3. After selecting This PC, you see a section called Devices and drives.

How to view free disk space and disk usage from the linux terminal

  1. Each storage device has a status bar, the amount of free space available, and the total disk space.

If you would like to view additional information, right-click the drive and select Properties from the drop-down menu that appears.

Windows 95, 98, NT 4.x, 2000, ME, and XP users

  1. From the Windows desktop, double-click the My Computer icon.
  2. In My Computer, highlight and right-click the drive whose capacity you’d like to determine.
  3. In the menu that appears, select Properties.
  4. The Properties window displays the used space, free space, and the total capacity of the hard drive or other drives.

Microsoft Windows 2000 and Windows XP users

If you are running Windows 2000 or Windows XP, My Computer also displays the total size and free space for each of the drives in the main window. If you want to view more information, and a graph of available space, follow the steps above.

You can also view the available space through MS-DOS.

MS-DOS and Windows command line users

To determine the available space on a hard drive using MS-DOS, we recommend using the dir command.

At the MS-DOS prompt, type:

At the end of the directory listing, you see information similar to the example below.

As you can see above, the hard drive has over 16 GB of free space. If you want to see all files and how much space they are occupying, type the following commands.

The command above lists all files on your computer (except hidden files) and displays the total amount of disk space they utilize, and free disk space.

  • See the dir command and cd command pages for further information about each of these commands.

Windows 3.x and NT 3.x users

In Windows 3.x or Windows NT 3.x, you can determine the available free space by highlighting the C: drive, and then looking at the status bar at the bottom of the screen.

You can also view the available space through MS-DOS.

Linux and Unix users

macOS

To determine how much drive space is available on your MacBook or iMac, follow the steps below.

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.

How to view free disk space and disk usage from the linux terminal

18 Answers 18

Open System Monitor from Dash and select the Filesystems tab.

How to view free disk space and disk usage from the linux terminal

Or alternatively open a Terminal and type:

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 :

How to view free disk space and disk usage from the linux terminal

Below is a sample screenshot of filelight :

How to view free disk space and disk usage from the linux terminal

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

How to view free disk space and disk usage from the linux terminal

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.

How to view free disk space and disk usage from the linux terminal

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

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

gnome-system-monitor or df -h or lsblk

Other useful utilities are baobab .

Free/used disk space is always related to a partition

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

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:

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.

Monitoring disk usage and storage space in your system is important for you as a stand-alone system owner or as a system admin of a company to know to maintain the efficiency of your Linux system. In this article, we will discuss about the top tools and command line utilities available in Linux to monitor your disk usage to provide information about total size available, total used, file system information and partition information etc. Let’s see how these tools help in retrieving this information:

1. df command

df is a Linux command line utility to monitor your Linux disk usage. The df command prints the complete summary of the disk usage details of your file system. With -hT switch along with df command, it displays details about the filesystem, type, total size of the disk, size used already, size still remaining, total used percentage level and where the disk is mounted on etc. in an easy readable format.

How to view free disk space and disk usage from the linux terminal

To display the disk usage of all file systems and its type in human readable format.

How to view free disk space and disk usage from the linux terminal

For more details of df of command refer this “ 11 df command examples in Linux

2. pydf command

pydf is a python command line utility and one of the best alternative for df command in Linux. It works similar to df command, but one difference is that the output is highlighted in different colors. Pydf command is not available by default in CentOS 7.x and RHEL 7.x. To install pydf on CentOS 7.x / RHEL 7.x , run the beneath commands one after the another.

Refer the below steps to install ‘pydf’ utility on Ubuntu 16.04/16.10 and Linux Mint 18

Display the output of all the file system using below command

How to view free disk space and disk usage from the linux terminal

Output of pydf command in human readable format

To list all the available options of pydf command , use the below command

How to view free disk space and disk usage from the linux terminal

3. fdisk Command

One of the most commonly used command line utility in Linux to monitor the partitions is the fdisk command. fdisk also called as fixed disk and fdisk helps you to get all details about the partitions in your system and also helps you to monitor, create, delete, move, copy any partition in your Linux system. With the fdisk command, data can be moved to a new disk as well. Make sure that you are a root user to run this command, or else you may get error “command not found”. Let’s see some of the basic fdisk commands and how does it help you in monitoring the partitions in your Linux system.

  • View all disk partitions
    One of the most commonly used arguments in fdisk command is the “-l” which lists all the available partitions in your Linux system with their device names.

How to view free disk space and disk usage from the linux terminal

  • View details about specific disk partition
    Argument “-l” is to view all the available partitions, you can also view details about a specific partition by providing the device name next to the “-l” argument like this below:
  • View all fdisk commands
    If you need to have a look at all the commands of fdisk for a particular hard disk /dev/sda, just type fdisk followed by the hard disk name like “fdisk /dev/sda” and in the following screen, type “m” to view all the commands for fdisk utility.

How to view free disk space and disk usage from the linux terminal

  • Print details about all partitions tables
    Like the previous operation, type “fdisk /dev/sda” and in the following screen type “p”, it will print all the details about that specific hard disk /dev/sda.
  • Delete a Partition
    To do any operation on any specific disk, you should be in the fdisk command mode of that particular hard disk like “fdisk /dev/sda” and enter d to being the delete operation. Once you enter “d” the system will prompt for which partition number need to be deleted and once you enter the partition number and then enter “w” to write the table to disk and exit the process. Please be careful with the delete operation as it would wipe out the whole partition and its data from your system.
  • Create new Partition
    To create a new partition, as usual be in the fdisk command mode “fdisk /dev/sdb” and enter “n” to create new partition and it will ask you to create whether a primary “p” or extended partition “e” and then enter the size of the cylinder by “+11G” where it means 11 GB will be set as the size for the cylinder.

4. sfdisk command

sfdisk stands for scriptable fdisk, sfdisk is a similar command like fdisk, but comes with more features than fdisk as it can display the partition size in MB. sfdisk also supports GPT, Sun, MBR and SGI partition tables, but sfdisk cannot create standard partitions for Sun and SGI disk label where as fdisk command is capable of creating partitions of these disks.

To display the size of partitions in MB, run the below command :

5. cfdisk command

cfdisk stands for curses fdisk, cfdisk is another command line utility that helps in managing your linux disk partitions with ease. With an easy to use user interface, one can easily create, edit, delete or modify your partitions.

Use the below command to view partitions of a specific disk using cfdisk

Apart from the above list “ parted command ” can also be used to create, edit and view the partitions.