How do I test the dimensions of a Folder in Linux


Linux provides you with more than a few superb command-line instructions that can assist in appearing more than a few duties. One of the key duties carried out from the command line of Linux is to test the dimensions of the record or folder. It could be essential to create space for the incoming record or switch it to some other location. Also, while you run some deployments, it has a tendency to create a log record routinely, and the distance will replenish with the ones log information. So we should monitor the distance of the record or folder and make area at the disk for them accordingly.

For this, you’ll desire a Linux machine, a command-line interface for operating the command, and the best consumer get admission to for checking the distance at the Linux machine.
We shall be taking a look at more than a few techniques to test the record or folder measurement to be had at the Linux machine.

Using du Command

The du within the “du” command specifies the disk utilization, which is to be had in all Linux distributions through default. Run the underneath command for checking the disk utilization to your Linux machine.

You gets the output exhibiting your house listing contents and a few numbers at the left appearing the thing’s measurement in KB.

If you wish to have the output in a extra readable layout, use the “-h” possibility and the “du” command, as proven underneath.

In the above output, you’ll see some numbers finishing with characters. The quantity specifies the volume of area used, and the nature will specify the (normally Okay, G, or M) kilobyte, gigabyte, or megabyte.

If you wish to have to test the dimensions of the listing this is other from the present listing, use the next layout for the “du” command.

The above command will assist in exhibiting the dimensions of the /var listing contents. You will understand an error within the underneath output because the consumer does no longer have the best permission for having access to that record. If you wish to have the best privileges, use the sudo or su command as discussed underneath.

If you wish to have to show the overall disk utilization for a selected listing, use the “-c” command as proven underneath.

To get the output in a human-readable layout, mix the “-c” possibility and the “-h” possibility, as proven underneath.

Well, you’ll be able to even put the restrict for exhibiting a definite degree of the subdirectory with the assistance of the “max-depth” possibility. Consider the underneath instance for exhibiting handiest the highest degree of the listing.

sudo du -hc –max-depth=0 /var

But if you wish to specify the main points of the highest listing degree along side the primary layer of the subdirectory, run the underneath command with the max_depth price as “1,” as proven underneath.

sudo du -hc –max-depth=1 /var

Using Tree Command

Some Linux variations should not have the tree command; you’ll be able to explicitly set up it as follows.

Using the tree command will show the visible illustration of your directories. You can use the tree command along side a number of choices for more than a few functionalities. For getting the output in human-readable layout, use the next command with the “-h” possibility.

You too can use the tree command if you wish to goal the particular listing.

If the equipped listing has a number of contents, the above command will take time to generate the output.

Using ncdu Command

The ncdu is often referred to as NCurses Disk Usage, which could also be no longer to be had in the entire Linux distributions through default. You can explicitly set up it the use of the underneath instructions for more than a few Linux distributions.

Use the ncdu command for purchasing the interactive show of the disk utilization.

You can see the present listing being scanned within the higher proper nook. In the left column, you’ll get the numerical measurement along side a graph of #- indicators specifying the relative measurement.

For settling on the other strains, you’ll be able to use the up and down arrows. With the best arrow, it is possible for you to to browse into the listing and the use of the left arrow, you’ll be able to return.

You too can use the ncdu command for focused on the particular listing.

For any assist with the ncdu command, you’ll be able to press the “?” key within the ncdu interface. If you wish to have to give up, you’ll be able to press the “q” letter.


While operating on a Linux machine, you should know the use of a disk and the dimensions of your information or directories. You can use more than a few instructions for the aim that we have got discussed above. You will also create a bash script for emptying the record if the dimensions exceeds a definite restrict the use of the disk utilization instructions. Once you get started operating on a Linux machine, you’ll test disk area instructions.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More