showing disk usage in human readable form

How to Check Disk Usage in Linux (4 Methods)

[ad_1]

There could also be occasions whenever you want to obtain some vital information or switch some photographs to your Linux system, however face an issue of inadequate disk house. You head over to your file supervisor to delete the massive information which you not require, however you don’t have any clue which ones are occupying most of your disk house. In this text, we are going to present some simple strategies to examine disk utilization in Linux from each the terminal and the GUI utility.

Monitor Disk Usage in Linux (2023)

Check Disk Space Using the df Command

In Linux, there are numerous instructions to examine disk utilization, the commonest being the df command. The df stands for “Disk Filesystem” in the command, which is a helpful approach to examine the present disk utilization and the out there disk house in Linux. The syntax for the df command in Linux is as follows:

df <choices> <file_system>

The choices to use with the df command are:

Options Description
-a Show details about all file methods together with pseudo, duplicate and inaccessible file methods
-h Display the sizes in human-readable format i.e in powers of 1024
-t Display the disk utilization of solely the file system of a selected sort
-x Display the disk utilization excluding a selected file sort

Display Disk Usage in Human Readable Format

The df command exhibits the sizes in bytes, which can be onerous for some individuals to learn. To see file sizes in a human-readable format corresponding to megabytes, gigabytes, and many others., then use the -h flag.Here’s what the syntax seems to be like:

df -h

showing disk usage in human readable form

Display Disk Occupancy of a Particular Type

You can even view the disk utilization of a selected file system sort utilizing the -t flag as proven under:

df -t <file_system_type>

disk usage of ext4 type partition using df command

Check Disk Usage utilizing the du Command

The df command solely exhibits the disk utilization for your complete file system and never for particular person information and directories. To view the disk utilization for particular person information and directories, use the du command. Here, du stands for “disk utilization“. The syntax to use the du command is:

du <choice> <file>

The choices to use with the du command are:

Options Description
-a Shows particulars of all information
-h Shows the file sizes in human-readable format
-s Displays the scale of a selected listing
-c Shows the full utilization of your complete listing

Display Disk Usage in Human Readable Format

To show the sizes in human readable format like in megabytes, gigabytes, and many others. as a substitute of bytes, use the -h flag by way of the command syntax under:

du -h

display sizes in human readable format

Display Disk Usage for a Particular Directory

The du command exhibits the disk utilization for all folders. But you may view the disk utilization for a selected folder, utilizing the -s flag with the fundamental command as beneath:

du -s -h <directory_name>

check the disk usage of a specific directory using du command

Compare Disk Usage of Two Directories

With the du command, it’s also possible to evaluate the disk utilization of two or extra directories as proven under:

du <choices> <directory_1> <directory_2>

comparing two directory sizes

Clean Disk Space Using the Command Line

You can use both of the du and the df instructions in mixture with different Linux instructions to checklist out the information and directories occupying essentially the most house. Then, you may select to hold these information or delete information in Linux to liberate space for storing in your pc.

Sorting Files based mostly on File Size

The du command shows the file measurement for all information in a listing, however when mixed with the kind command utilizing the pipe character ‘|‘, you may see the outcomes sorted in reducing order of their file measurement. The syntax to use each instructions is:

du -a <directory_path> | type -rn

Here, the pipe character ‘|‘ is used to ship the output of 1 command because the enter for an additional command. In the second a part of the syntax, the -r flag is used to type in reverse order and the -n flag is used to type information based mostly on the numeric worth. However, don’t delete information simply on the idea of file measurement as you can by accident delete vital information that are required for the functioning of the Linux system.

sorting all files based on file size

Exclude Files Based on Their File Size

There are quite a few methods to exclude information based mostly on their file measurement by combining varied instructions, however the easiest method is to use the discover command to exclude information exceeding a sure measurement. The syntax to use the discover command to exclude information based mostly on their file measurement is:

discover <directory_path> -size -<file_size_to_exclude>

You can even use the -exec flag to mix with different instructions, taking the output of the discover command because the enter for the opposite command.

Excluding files based on file size

Exclude Files Based on their Types

The du command has a vital flag referred to as the --exclude flag, which can be utilized to exclude sure file sorts when the command is used in mixture with different instructions. The syntax to use the --exclude flag with the du command is:

du -h <path_to_directory> --exclude="*<file_extension>"

Here, the * is used as a wild card which signifies that each one the characters ought to match the enter whereas parsing the listing.

excluding items using wild card

Check Disk Usage Using GUI

The command line output for varied disk utilization instructions will be onerous for some individuals to perceive. So there are some GUI alternate options that make the duty of monitoring disk utilization simple. Some frequent GUI instruments to monitor disk utilization are the GDU Disk Usage Analyzer and the Gnome Disks Tool,which will be simply put in utilizing the next command:

Installing disk utilization analyzer:

sudo snap set up gdu-disk-usage-analyzer

Installing disk-utility device:

sudo apt-get -y set up gnome-disk-utility

Check Disk Usage Using Gnome Disk Tool

The Gnome disk utility device is usually used to format storage partitions to a selected sort. In the default view, all of the storage partitions are proven.

To know particulars a few partition such because the machine title, file system sort, out there house, and extra, you want to click on on the partition’s title. The disk utility device is a useful gizmo, however you may lose all of your vital knowledge if used carelessly.

checking available disk space using Gnome Disks Tool

Check Disk Usage Using Disk Usage Analyzer Tool

Monitoring disk utilization is far simpler in GUI utilizing the Disk Usage Analyzer Tool as in contrast to CLI. After putting in this device, entry it by way of the Applications menu after which observe the steps under:

1. When you first open the Disk Usage Analyzer device, it would present all of the storage partitions linked to your system alongside along with your Home listing.

listing all partitions attached to the system

2. To know in regards to the disk utilization of any machine, click on on the machine title. It will scan your complete machine and show a hoop chart of the disk occupancy for all of the folders. When you hover over any portion of the graph, you will note which folders are occupying essentially the most disk house.

Ring chart for disk occupancy

Cleanup Disk utilizing Disk Usage Analyzer

After analyzing completely different areas of the file system, you may want to delete among the storage hogging information. The Disk Usage Analyzer Tool additionally doubles up as a cleanup device for the information or folders you need to delete. To delete any information or folders:

1. Navigate to the file you need to delete from the file system tree. Right-click on the merchandise and choose the “Move To Trash” choice.

deleting a folder using the Disk Usage Analyzer

As a security measure, this device strikes the information and folder to the “Trash” location, so that you just don’t delete an vital file by chance. The trash location can then be emptied utilizing any file supervisor.

Easily Check Disk Usage in Linux

Managing disk house is a crucial ability for file administration, and it’s essential to hold disk drives wholesome for a very long time. We hope that the strategies proven in this information will assist you examine disk utilization in Linux. If you face any points, do tell us in the feedback under.

[ad_2]


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *