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

藏色散人
藏色散人Original
2023-01-04 14:56:1648320browse

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.

How to check the space occupied by a directory in Linux

#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

How to check the space occupied by a directory in Linux

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn