Linux statistics folder space usage-basic usage of the du command, linux-du
In the command line environment, you need to know the space occupied by a folder in the linux System and the files it contains. The command du provided by linux can meet the requirements well.
I will not write out other usage items one by one, but I think it will be the most useful, directly:
$ Du-sh. /* 118 M. /Chemi4.0K. /CollectionFramework32M. /C Programming version 4. tan haoqiang. scanned version 7.7m. /jsfPPT360M. /Mooc34M. /mvnt1.4G. /Reference251M. /compressed package 20 K. /interview. odt
The first column of the output result is the volume occupied by the file or folder, and each folder is on the right.
The options are as follows:
-S is used to calculate the total space occupied by various directories. If not, it recursively lists a lot of useless information;
-H is easy to understand, that is, to select an appropriate unit. Some of the above use M and some use G, which makes it clear that du is used here, for details about other options, refer to man page.
The wildcard is used to list all files or folders in the current directory. Otherwise, only the total size of the current directory is listed.
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In addition, you may also think of the ls command. The general usage is as follows:
$ Ls-alhtotal 2.0Mdrwxr-xr-x 42 prompt 4.0 K December 2 13:44. drwxr-xr-x 6 root 4.0 K July 23 16:29 .. drwx ------ 3 prompt 4.0 K August 19 10:25. adobedrwxrwxr-x 3 prompt 4.0 K July 23 15:07. AMD-rw-r -- 1 prompt 140 August 6 10:58. appletviewer-rw-r -- 1 prompt 86 August 17 22:10. asoundrc-rw ------- 1 prompt 17 K December 1 22:59. bash_history-rw-r -- r -- 1 prompt 220 July 23 14:16. bash_logout-rw-r -- r -- 1 prompt 3.9 K August 21 22:14. bashrcdrwx ------ 29 prompt 4.0 K December 1 15:17. cachedrwx ------ 3 prompt 4.0 K July 23 15:12. compizdrwx ------ 34 prompt 4.0 K December 1 15:17. configdrwx ------ 3 prompt 4.0 K July 23 15:25. dbusdrwxr-xr-x 2 prompt 4.0 K December 1 15:03 Desktop-rw-r -- 1 prompt 25 July 23 15:12. dmrcdrwxrwxr-x 9 prompt 4.0 K December 2 14:43 Documentsdrwxrwxr-x 7 prompt 4.0 K December 1 21:00 Downloads
Here, we should all know in the ls option (-a displays all files and folders, including. -l lists the details, such as the occupied space and the user.-h displays the occupied space in a proper unit, such as M or G ), the file size is 4.0 kb. Obviously, it contains more than that.