Disk space monitoring is considered very important when working with any device, whether it’s a mobile phone, laptop, desktop or even a tablet. It is important to ensure the proper operation of each device by checking the amount of disk space. This helps you identify programs or applications that use a lot of memory and lets you know when the memory is depleted.
Like any other operating system, Linux offers several ways to track the disk space of your device, including methods based on the graphical user interface (CLI) and the programming interface (GUI). Under Linux, however, most operations are performed on the command line. This is why Linux users are more interested in methods to control disk space from the command line. That’s why our discussion today focuses exclusively on methods to control disk space in Linux from the command line.
Pay attention: All of the following methods have been tested on Linux Mint 20.
Checking the Linux disk space from thecommand line
There are several ways to control disk space under Linux, but the most efficient one, using the command line interface, is shown below.
Method 1: Use the command df
The df command stands for Disk Filesystem and is an integrated utility with different flavors of the Linux operating system. The df command is used to monitor the use of disk space and all available space. To check the disk space with this utility, follow the steps below:
First run the terminal on Linux Mint 20 by clicking on the desktop icon in the figure below:
After running the terminal in Linux Mint 20, execute the following command in the terminal
When you execute this command, the total disk space of the entire file system, the total amount of disk space used and the available disk space are displayed, along with some other data, as shown in the following figure :
Method 2: Use df instruction with flag -a
The df command can also be used in conjunction with the -a flag, which is used to indicate disk space on all filesystems (i.e. both your real filesystem and dummy systems). Follow the steps below to use the df command with the -a flag
Boot the terminal on Linux Mint 20 and execute the command below:
The output of this command will be large enough, and you will have to scroll through the terminal to see the full output. Indeed, a flag not only prints space on one file system, but on all available file systems.
Method 3: Use of df instruction with flag -h:
Some technical terms may not be clear to the new user. In the results of the two methods discussed above, you can see, for example, the 1K-block column. This column contains the total number of 1K blocks present in each file system. In other words, it is the size of the file system in bytes that can be difficult to interpret and remember. Basically, it’s a technical way of showing the size of any file system, but for a layman it’s not that intuitive. Therefore, the -h flag can be used with the df command to display disk space in a more human readable format. To do this: 1 :
Boot the Linux Mint 20 terminal as described above, and then execute the following command:
When you run this command, the disk space of your file system is displayed in a way you can easily interpret, i.e. the disk space is displayed in megabytes (MB), gigabytes (GB), and so on. You can see this conclusion in the figure below:
In the same way you can use the -k and -m flags with the df command to check the disk space in kilobytes and megabytes respectively from the command line under Linux. This is possible if you need storage space in a particular camera for a particular lens. If you allow it, the df command or utility allows you to check your disk space in the format you prefer.
This article showed how to check the available disk space on a device using the Linux command line. The three methods described above were a variant of the df command. With the df command you can easily check the disk space under Linux from the command line by setting the flags if needed. Or you can just use this team alone and without flags. With the output of this command, you can see the current memory usage and the amount of free space.
In addition to using the df command discussed in this article, this command can also be used to check the disk space of a particular file system, find the total number, available and used file system codes, check the type of each file system, filter file systems by a particular type, and much more. However, not all of these uses fall within the scope of this Article. We have therefore only focused on the use of the df command, which is meant to control the disk space.License Type: Read Only