Home>Article>Operation and Maintenance> How to check the space occupied by a directory in Linux
How to check the space occupied by a directory in Linux: 1. Use the "du -h --max-depth=0" command to check the total space used by the current directory; 2. Use "du -h --max -depth=1" command to view the space used by a file in the current directory.
#The operating environment of this tutorial: linux7.5 system, Dell G3 computer.
How to check the space occupied by a directory in Linux?
Linux View the total space occupied by the current directory
View the total space occupied by the current directory
du -h --max-depth=0
View the space used by a file in the current directory
du -h --max-depth=1 文件名
Among them, "--max-depth=" specifies the number of levels deep into the directory (if this parameter is not used, the list will be looped The space used by all files and folders in the current directory, which will be messy if there are many files):
(1) --max-depth=0: View the total space used by the current directory;
( 2) --max-depth=1: View the total space used by the current directory and the total space used by files and folders below the current directory;
Note:
du It means disk usage
--max-depth is equivalent to -d
-h which means user can understand The space size unit, such as k, m, g
Common commands:
du -hd0: Indicates querying the total space size in the current directory
du -hd0 Specifies the directory: Indicates querying the total space size of the specified directory under the current directory
du -hd1 : Indicates querying the current directory separately The total space size of each directory under the directory
Recommended study: "Linux Video Tutorial"
The above is the detailed content of How to check the space occupied by a directory in Linux. For more information, please follow other related articles on the PHP Chinese website!