Linux Server

How to Check Disk Space on Linux?

First, check the totally free or left disk space on your Linux server. 

Disk Space Management is very prominent in Linux or any other server. It plays an important role from installing any applications to running applications efficiently on your server. For example, if you want to install any program and package on your server. At that time, package manager applications ask you how much space is required for a successful installation. So, to keep that information more meaningful, you should know how much space is available on your system. 

So, basically, through this guide, we drive you into the subsequent divisions to take a pit closer at the insights on how to check Disk Space on Linux Server using df and various other commands. Let’s get started!

Check Disk Space Linux using df Commands

To check Disk Space on Linux, open the terminal window on your system, and type the “df” command. It displays the information and data of your Device name, the number of blocks, total disk space,  used disk space, available disk space, mount points, and so on currently available on your file system. In simple terms, it shows the complete statistics of your disk space.

OUTPUT:



The df stands for “Disk Free.” It shows or displays the amount of disk space consumed by each drive in your system. By default, the Disk Free (df) command displays the values in 1-kilobyte blocks.

Display Disk Space Usage in Bytes

To get the output in Bytes, use the command “-k“. It displays all the files used in 1024-byte blocks stored on the drives of your system.  

For example: –block-size=1K

OUTPUT:

Display File System Information in MegaBytes 

To display file information stored in your system consuming disk space in MegaBytes, abbreviated as MB, use the commands “-m“.

OUTPUT:

Display File System Information in Gigabytes

To display file statistics of using disk space in GigaByte (GB), use the code “df -h.”

OUTPUT:

Check Disk Space on Linux in Megabyte and Gigabyte

If you can’t understand the computer language, you can make it a more human-readable format by using the “-h” option.

So, the command will be “df -h

Data Size is displayed in kilobytes (K), megabytes (M), and gigabytes (G).

OUTPUT:


Understanding The Format of Output

Here are the several columns comprising the list of df Command:

FilesystemSizeUsedAvailUse %Mounted on
Udev210M0210M 0/dev
tmpfs49M1004K 48M3/run
/dev/sda27.9G4.3G3.2G58/

If your output comprises more entries, then columns are automatically expanded in the Filesystem distribution:

Filesystem: Particular drive names(physical, logical, virtual, and temporary drives).

Size: Display the data size of the filesystem.

Used: It shows the amount of disk space used by the data or drives on your system.

Avail: It displays the amount of available disk space in your file system distribution.

Use %: It shows the used disk space value in percentage.

Mounted On: It is the directory where your file system is actually located in your system. Mounted on also known as “Mount Point.” 

Note: Filesystem list includes both physical and Virtual Hard Drives:

/dev/sda2 – It is a physical hard drive that seems like /sda1, /sda0. You have more than one ./dev that stands for a physical device.

udev – It is a virtual directory for the /dev directory. We can say a part of the Linux OS.

tmpfs – You may have more than one tmpfs. It is a temporary filesystem that is basically used by the /run and run the Linux OS process.

To lock the files, use the “tmpfs /run/lock“. These commands prevent multiple or unauthorized users from making alterations and configurations on the same file simultaneously. 

Check Free Disk Space Linux on all File System

It is somewhat similar to checking the stat of your disk space. But, it also displays the rest of the files’ information present in your file system rather than the useful data. In simple terms, you can check how much disk space is consumed by the dummy file systems and their memory utilization. 

Display File System by Type

Use the “df -ht ext4” command to list all the file systems files by their type.

ext4type is used to display the output in a human-readable format.

OUTPUT:

Display File System Inodes

To display system inodes(information of a number of nodes your system is using) and respective percentage values for the file system, use “-i” command. 

OUTPUT:

Display a Certain File System

To display certain file systems on your window terminal, use “-t” command. 

Example: This command only displays the ext4 file system.

OUTPUT:

Show Disk Space in Human Readable Format

If you noticed that all the data yet displayed is in the bytes that humans cannot understand. This is because humans are habitual to read the data in megabytes, gigabytes, etc. It makes data easier to comprehend. 

Whereas the command “df” ensures all data must be displayed in Human Readable Formats if you use the “-h” command. 

OUTPUT:


Check Available Disk Space Linux using du Commands

As you are aware for now, that du command is used to display disk space. This command displays disk space usage by the individual task in your system by the individual Linux directories. Use the “du” command to check the available disk space on Linux in your current directory.  

OUTPUT:

Like df, you can use the du command to make a human-readable format:

du -h

Once you type the command and hit the enter button, it shows you a list of available content in your present directory on your terminal window screen. It shows you the usage of disk space by a task in your current directory. To simplify the display, you can use “-s” option.

This show your Output like:

OUTPUT:

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

To display file directory and Linux Command to check disk space, use options:

du -hs /etc/kernel-img.conf

du -hs /etc

With the second command, an error message displayed on your terminal message “permission denied”. This means the current user can not access the specific directories. Therefore, to ensure all access to your current directory, use the “sudo” command.

sudo du -hs /etc

In Conclusion

With the complete insights of this guide, you’ll now be aware of how to use the various commands to check the disk space, especially with the df and du on your Linux system. Keep in mind that to display the file system’s complete list in your current directory, use either df –help or du –help.

I hope this guide helps you to check the complete disk space statistics of your current directory in your Linux Server. 

Get in Touch

Arpit Saini

He is the Director of Cloud Operations at Serverwala Cloud Data Centers Pvt Ltd and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles

Adblock Detected

Please consider supporting us by disabling your ad blocker