How to see the size of a directory within LINUX? –

The Linux operating system allows you to use a robust terminal to know the size of files, folders and even see partitions and disks without the need to use an interface. For this reason, if you are interested in knowing how to see the size of a directory within LINUX , in this valuable tutorial we will show you the procedure to achieve it.

Index( )

  1. What ways can you see the size of the directory in LINUX?
    1. in long format
    2. See them by classification
  2. What methods are there to see the weight of a directory within LINUX?
    1. With the 1s command
    2. The ‘du’ command and its variants

What ways can you see the size of the directory in LINUX?

If you decide to download Ubuntu Linux or any other version, you should know that the space occupied by files and directories is allocated in blocks within the system.

In this regard, two measures are used: the first defines the real size, while the second reflects the number of bytes that the file or directory occupies. The latter is the number of file system blocks required for storage.

There are two ways to see the size of the directory in LINUX. One of the options is to use commands in the terminal with long format although you can also see them by classification. One way or another, you will be able to get the length of the directory in blocks of bytes, kilobytes, and megabytes.

in long format

It is possible to see the size of a directory within LINUX in long format. For this, open a terminal by pressing the ‘Ctrl + Alt + T’ keys. Type the command ls –l folder_name and press ‘Enter’ to see permission information, owner name, group name, size, creation date and time of the files.

See them by classification

Likewise, it is possible to see the size of a directory within LINUX by classification. To achieve this, open a terminal using the ‘Ctrl + Alt + T’ key combination and access a particular directory. Then, type ls –F and press the ‘Enter’ key. In this way, you will be able to see the type of user that has access to a particular directory.

What methods are there to see the weight of a directory within LINUX?

Just as it is possible to change the size of folders in Windows , methods can also be used to see the size of a directory within LINUX by means of the ls command and the du command with its variants. The ls command has several parameters in order to access the long format, by classification or the human format to see the size in bytes and MB.

With the 1s command

The command allows you to view the list of files and directories that are in a specific location on computers with the LINUX system. This command has various parameters, such as the ‘ls –a’ command, which is used to view hidden files and folders, or ls –t, which is used to sort files according to modification date.

In addition, the command displays detailed information about a directory such as permissions, user and group names, file sizes along with the creation date and time using ‘ls –l’. Another parameter is ‘ls –lh’ which will be used to see the size in KB, MB and GB and ‘ls –R’ which allows showing the subdirectories in recursive mode.

The ‘du’ command and its variants

The ‘du’ command allows you to see the amount of space occupied by files and directories that are specified in a LINUX terminal . If you write the location of a directory, the command will take care of showing the space that each subdirectory occupies on the hard disk. If the path is not indicated, only the space occupied by the current directory is shown.

The ‘du’ command by itself only displays the space in bytes that both the current directory and its subdirectories occupy on the hard drive. You can even add several variants such as ‘du s’ to show the total size of a particular directory, ‘du h’ to see the size in MB or GB and du /var to see the directory path.

With the ‘du’ command you can access top-level subdirectories by typing du -shc /var/*. In addition, it is possible to display a report about the usage of the top-level subdirectories on the disk through the du –h –max depth = 1 /var command. If you prefer to see the apparent size of a directory you should type du –sh –apparent –size /var.

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment