How to Check Disk Usage in Linux/Ubuntu?

As a Linux System administrator, you must continuously manage your disk to keep it in an optimal state and always available. The perfect way to do that is to be aware of the available disk Usage on the Linux Machine. Fortunately, Linux has built-in commands that assist the administrator in overseeing disk usage.

This guide will show you the commands and their usage when it comes to checking and observing the Linux Disk Usage.

How to Check Disk Usage in Linux?

To check the disk usage in Linux, you can utilize the built-in “df” and “du” commands, as they both come with additional options that can be used to specify the directory/drive and also to format how the result is displayed on the terminal. 

Alternatively, you can use the GUI tool “Disks” in Debian-based Linux distributions like Ubuntu. However, different variants of Linux might have different tools for checking the status of the disks. 

The df Command to Check Disk Usage

The “df” command, which stands for disk free command, is used to get information about the free disk space along with the disk usage in Linux, and it doesn’t require any special privileges to execute.

To use the disk free command, open a new terminal session and execute the following command:

df

The output of the command displays the information in the form of kilobytes, as shown in the image below:

However, you can easily format the result using the “-h” option, which stands for human-readable format. To do this, execute:

df -h

There are a lot of different options available that can be utilized to format the output further according to a specific requirement. To view these options and to understand the syntax of the “df” command, you can view the manual of the disk-free command by executing the following command:

man df

The manual page of the “df” command shows the following information:

Some of the important and most used options contain the “–o,” which shows a detailed variant of the result containing more fields than the basic one. The output with this option is as follows:

Moreover, to get the information on all the disks and mounts available on your linux machine, you can utilize the “-all” option:

Another useful option that allows you to format the result with respect to the disk type is the “-T”:

The du Command to Check Disk Usage

Another command line utility is the “du” command, which allows the user or the administrator to observe the disk usage on the terminal. However, the “du” command displays the disk usage command and shows the information for every file and folder in the Linux system or the specified directory.

To get the basic output, open a new terminal session and execute the following command:

du 

However, knowing the information of every file and folder in your Linux machine is not that useful. Therefore, you must utilize the available options to get a better-formulated output. To know these options and the syntax of the “du” tool, refer to the manual of “du” by running the following command:

man du

Just like the “df” command, you can format the result in a human-readable form by applying the “-h” option.

Similarly, the “-a” option can view all files and directory information. However, a more suitable option is the “-hs,” which gives the summary of the total disk usage in a one-line output and a human-readable format:

The Disks tool to Check Disk Usage

As mentioned above, Debian-based Linux variants (and other modern variants) come with different GUI tools that allow users easy access to different features. In Ubuntu, the tool to view disk information is called “Disks.”

You can find this tool in the applications drawer, or you can open “Applications” and search for Disks:

In the disks application, select the disk from the left-side navigation panel, and then the explore tab will display the disk information summary:

Dedicated Virtualization Server with KVM Technology

Enhance your Linux experience with Dracula Servers’ Dedicated Servers, offering a powerhouse of resources for those who demand top-notch performance and control. What sets Dracula Servers apart is the implementation of KVM (Kernel-based Virtual Machine) – True Emulation Virtualization Technology. This cutting-edge technology ensures a secure, isolated, and efficient virtualization environment for your Linux projects. With KVM, you get true hardware-level virtualization, allowing you to run a wide range of Linux distributions without compromise. Dive into the world of dedicated servers backed by KVM technology and experience unparalleled flexibility and reliability for your Linux endeavors.

Explore the benefits of Dracula Servers’ Dedicated Servers for Linux at Dracula Servers KVM VPS.

How to use the “ls” Command to Check Disk Usage of Files and folders?

If you want to find the disk usage of the size of files and folders inside the particular directory, then instead of using the “df” or the “du” command, you can utilize the “ls” command. However, you will have to use the “-al” option that will list all of the files and folders along with their size. Lastly, you can also include the “h” option to format the output in the human-readable format.

To do this, first head inside the directory by using the “cd” command, and then execute the command:

ls -alh

The terminal will show the results in the following manner:

Wrap Up

If you are looking for a quick and easy way to check the Disk Usage in Linux, then you can use the “df” and the “du” command-line utilities. Both of these command line tools come with various options that help you fine-tune your output according to your needs. Moreover, you can easily convert the result that is displayed into a more human-readable format by adding the option “-h.”

Apart from these, in modern Linux Variants, GUI tools (Like Disks in Ubuntu) can help you get a summary of disk usage. To utilize this, you will have to open up the applications tray and open the Diks tool. After that, select the disk whose information you want to fetch.

FAQs

Here are some of the most frequently asked questions related to checking the Disk Usage in Linux and Ubuntu.

Q: How do I check the available disk space in Linux using the command line?

A: To inspect disk space in Linux, simply open a terminal and type the command “df” to see detailed information about the disk usage for each file system on your machine.

Q: What’s a straightforward way to view the available disk space in Linux?

A: Use the “df” command with the “-h” flag to view free disk space in a human-readable format.

Q: How can I check the unused disk space in Linux?

A: To determine unused disk space in Linux, use the “df” command with the “-a” option. This will reveal available space for every file system, even if fully occupied.

Q: Is it possible to check disk space on a remote Linux server?

A: Yes, you can check disk space on a remote Linux server by using the “df” command. SSH into the remote server and run the “df” command as you would on a local machine.

Q: How can I determine storage utilization for a specific directory in Linux?

A: To examine the storage consumption of a specific directory in Linux, use the “du” command followed by the directory’s path. For example, to check storage used by the /home directory, execute “du /home.”

Q: Is it possible to determine storage utilization for an individual file in Linux?

A: Yes, in Linux, you can assess the storage usage of a particular file using the “du” command with the file’s path. However, note that the primary function of “du” is to evaluate the storage consumption of directories.

Q: How can disk space utilization be presented in a user-friendly format?

A: Utilize the “df” command with the “-h” option to display disk space in an easily understandable format, showing sizes in MB or GB instead of standard 1K blocks.

Q: How do the “df” and “du” commands in Linux differ when examining disk space?

A: The “df” command provides an overview of disk space utilization on entire file systems, while “du” focuses on space occupied by individual files or directories. In essence, “df” offers a system-level view, whereas “du” allows a detailed exploration of specific directories or files.

Check out More Linux Tutorials Here!

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
× Dracula Servers

Subscribe to DraculaHosting and get exclusive content and discounts on VPS services.