Method: 1. Use the ls command to view the results. This command can display the results in KB, MB, etc. The syntax is "ls -ll" or "ls-lh"; 2. Use "du - h –max-depth=1 *” command, this command can view the size of each file and folder in the current directory; 3. Use the “du -sh” command to view the total size of the current folder; 4. Use “ du -h –max-depth=0 *” command, you can view the size of direct subdirectory files and folders.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
1. The simplest way to check is to use the ls -ll and ls-lh commands. When using ls -ll, the size in bytes will be displayed. , and ls-lh will be displayed in units of KB, MB, etc., which is more intuitive.
2. Through the command du -h –max-depth=1 *, you can check the size of each file and folder in the current directory. This is more practical.
#3. To query the total size of the current directory, you can use du -sh, where s represents the meaning of statistical summary, that is, only a total size is output.
4. Similarly, through the command du -h –max-depth=0 *, you can only display the size statistics of direct subdirectory files and folders.
#5. If you only want to view the total size of the specified directory, you can use du -sh directory name.
#6. You can also specify the display level depth for the specified folder, such as du -h --max-depth=0 software/ and du -h --max-depth =1 software/
Recommended learning: Linux video tutorial
The above is the detailed content of How to check the size of a folder in Linux. For more information, please follow other related articles on the PHP Chinese website!