Home > Article > Operation and Maintenance > What is the size of the linux folder du
In Linux, the du command is used to estimate the disk usage of a directory or file. It can recursively calculate the size of all files and subdirectories in the directory and display the size in bytes. The command is "du -s /path/to/directory", the du command will calculate the size of the entire directory, including all its subdirectories and files.
The operating system of this tutorial: Linux5.18.14 system, Dell G3 computer.
In Linux, the du command is used to estimate the disk usage of a directory or file. It recursively calculates the size of all files and subdirectories in a directory and displays the size in bytes.
To check the size of the folder, you can use the following command:
du -s /path/to/directory
Among them, /path/to/directory is the path of the folder you want to check the size of.
This command will output a number indicating the total size of the specified folder (in bytes). If you want to display the size in a more readable way (such as KB, MB, GB), you can add the -h option:
du -sh /path/to/directory
At this point, the output will be displayed in a human-readable format.
Please note that the du command calculates the size of the entire directory, including all its subdirectories and files. If you only want to calculate the direct size of a directory without including subdirectories, you can use the -d parameter to specify the depth level. For example, if you only want to calculate the size of one-level subdirectories, you can use this:
du -sh -d 1 /path/to/directory
This will only calculate the size of the direct subdirectories of the specified directory.
The above is the detailed content of What is the size of the linux folder du. For more information, please follow other related articles on the PHP Chinese website!