how to check the current disk space usage in linux

It is not uncommon to have to check the disk or drive on your machine to see if there is enough space left on it. Keeping enough free disk space allows you to save more files and images, install new software and even run the operating system better and faster. The method to check for the current status of the hard disk depends on the operating system itself.

In Linux and Unix operating systems, the command to find the total amount of disk space and the disk space in use is df. df is an abbreviation for Disk Free and this program displays the amount of disk space in Linux that is free for use.

The df command displays the disk space for every mounted file system on your machine, if you do not specify a specific file system or a command line argument in the command line. You can specify the file system name in the command line as an argument if you prefer to see the details of only a particular one.

output of df command in linux

bash$ df /dev/sda1

The above command example will print out the details for the disk mounted at /dev/sda1.

There are several different options available which allows you to format the output of the command better. Not all of the options are commonly used, hence we will look at just a couple of the more useful options. If you like to see the complete list of options available, refer to the local man page of df or see the online version.

human readable format

-h option prints out the numerical values in kilobytes (KB), megabytes (MB) and gigabytes (GB) which are easier to read.

human readable output of df command in linux

all file systems

-a option prints out the information for all file systems including the dummy file systems. This is useful if you like to view the file systems like usb and proc.

You can specify the format of the command output by specifying the -P option, which prints out in the standardized POSIX format. This is usually the default in almost all of the latest versions. The output for each of the mounted filesystem is denoted in a single line in the following column order:

<File System Name>, <Total Disk Space>, <Used Space>, <Available/Free Space>, <Percentage of Disk Space used>, <Mount Point of the FS>

All of these fields should be pretty self explanatory. The most important one is obviously the available or free space column which shows you the amount of space left for you to use.

Another command that can be used is fdisk. Though the fdisk  command, which stands for Fixed Disk, is not as informative as the previous df  command, you can find other details about your mounted disk. It also prints out the total space of the hard disks mounted on your system. Note that you would require super user (or root) role to execute this command.

Use fdisk -l to print out detailed information on your disk partitions

Screenshot of fdisk command

bash$ fdisk -l

The highlighted region in the screenshot shows where you can find the total disk space of your mounted file system. The rest of the output is useful information which shows you detailed information from your master boot table about your disk partitions.