{"id":8048,"date":"2024-04-21T19:01:01","date_gmt":"2024-04-21T11:01:01","guid":{"rendered":""},"modified":"2024-04-21T19:01:01","modified_gmt":"2024-04-21T11:01:01","slug":"linux\u6839\u76ee\u5f55\u6ee1\u4e86\uff0c\u600e\u6837\u5feb\u901f\u67e5\u770b\u662f\u54ea\u4e2a\u6587\u4ef6\u5360\u7528\u7a7a\u95f4\u5927","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8048.html","title":{"rendered":"linux\u6839\u76ee\u5f55\u6ee1\u4e86\uff0c\u600e\u6837\u5feb\u901f\u67e5\u770b\u662f\u54ea\u4e2a\u6587\u4ef6\u5360\u7528\u7a7a\u95f4\u5927"},"content":{"rendered":"
<\/pre>\n\n
- \n
linux\u67e5\u770b\u6839\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u5939\u5927\u5c0f\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/code><\/p>\n<\/li>\n
- \n
1\u3001\u8fdb\u5165\u6839\u76ee\u5f55\uff1acd \/<\/code><\/p>\n<\/li>\n
- \n
2\u3001\u4f7f\u7528\u547d\u4ee4 \uff1a du -sh * \u67e5\u770b\u6839\u76ee\u5f55\u4e0b\u6bcf\u4e2a\u6587\u4ef6\u5939\u7684\u5927\u5c0f<\/code><\/p>\n<\/li>\n
- \n
3\u3001\u8fdb\u5165\u5360\u7528\u7a7a\u95f4\u6bd4\u8f83\u5927\u7684\u6587\u4ef6\u5939\uff0c\u7136\u540e\u518d\u4f7f\u75282\u4e2d\u547d\u4ee4\u67e5\u627e\u5927\u6587\u4ef6\u3002<\/code><\/p>\n<\/li>\n<\/ol>\n
du -ah --max-depth=1 \u8fd9\u4e2a\u662f\u6211\u60f3\u8981\u7684\u7ed3\u679c a\u8868\u793a\u663e\u793a\u76ee\u5f55\u4e0b\u6240\u6709\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939\uff08\u4e0d\u542b\u5b50\u76ee\u5f55\uff09\uff0ch\u8868\u793a\u4ee5\u4eba\u7c7b\u80fd\u770b\u61c2\u7684\u65b9\u5f0f\uff0cmax-depth\u8868\u793a\u76ee\u5f55\u7684\u6df1\u5ea6\u3002<\/code>\ndu\u547d\u4ee4\u7528\u6765\u67e5\u770b\u76ee\u5f55\u6216\u4ef6\u6240\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002\u5e38\u7528\u9009\u9879\u7ec4\u5408\u4e3a\uff1adu -sh\n<\/pre>\n
\u4e00\u3001du\u7684\u529f\u80fd<\/p>\n
`du` reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments). with no arguments,`du` reports the disk space for the current directory\u3002<\/code><\/pre>\n
\u3000\u3000\u5f88\u660e\u663e\uff0c\u4e0edf\u4e0d\u540c\uff0c\u5b83\u7528\u6765\u67e5\u770b\u6587\u4ef6\u6216\u76ee\u5f55\u6240\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002<\/p>\n
\u4e8c\u3001du\u5e38\u7528\u7684\u9009\u9879\uff1a<\/p>\n
\u3000\u3000-h\uff1a\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u65b9\u5f0f\u663e\u793a<\/p>\n
\u3000\u3000-a\uff1a\u663e\u793a\u76ee\u5f55\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\uff0c\u8fd8\u8981\u663e\u793a\u5176\u4e0b\u76ee\u5f55\u548c\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f<\/p>\n
\u3000\u3000-s\uff1a\u663e\u793a\u76ee\u5f55\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\uff0c\u4e0d\u8981\u663e\u793a\u5176\u4e0b\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f<\/p>\n
\u3000\u3000-c\uff1a\u663e\u793a\u51e0\u4e2a\u76ee\u5f55\u6216\u6587\u4ef6\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\uff0c\u8fd8\u8981\u7edf\u8ba1\u5b83\u4eec\u7684\u603b\u548c<\/p>\n
\u3000\u3000--apparent-size\uff1a\u663e\u793a\u76ee\u5f55\u6216\u6587\u4ef6\u81ea\u8eab\u7684\u5927\u5c0f<\/p>\n
\u3000\u3000-l \uff1a\u7edf\u8ba1\u786c\u94fe\u63a5\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f<\/p>\n
\u3000\u3000-L\uff1a\u7edf\u8ba1\u7b26\u53f7\u94fe\u63a5\u6240\u6307\u5411\u7684\u6587\u4ef6\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f<\/p>\n
\u3000\u30001\u3001du -h\uff1a\u8fd9\u4e2a\u5c31\u4e0d\u591a\u8bf4\u4e86\u3002<\/p>\n
\u3000\u30002\u3001<\/p>\n
A\u3001du -a\uff1a\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u663e\u793a\u76ee\u5f55\u548c\u76ee\u5f55\u4e0b\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002<\/p>\n
<\/p>\n
\u53ef\u4ee5\u770b\u51fa\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0bdu\u53ea\u663e\u793adownload\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\uff0c\u800c\u4f7f\u7528-a\u9009\u9879\u540e\uff0c\u5b83\u4e0d\u4ec5\u663e\u793a\u4e86\u76ee\u5f55\uff08\u6700\u540e\u4e00\u884c\uff09\uff0c\u800c\u4e14\u663e\u793a\u4e86\u76ee\u5f55\u4e0b\u5404\u4e2a\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002<\/p>\n
B\u3001du -s\uff1a\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0cdu\u53ea\u663e\u793a\u76ee\u5f55\u6240\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\uff0c\u800c\u4e0d\u663e\u793a\u5176\u4e0b\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u4fe1\u606f\u3002<\/p>\n
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cdu\u4e0d\u663e\u793a\u76ee\u5f55\u4e0b\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u4fe1\u606f\uff0c\u4f46\u5b83\u4f1a\u663e\u793a\u5176\u4e0b\u5b50\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u4fe1\u606f\uff1b\u800c\u4f7f\u7528-s\u9009\u9879\u4ee5\u540e\uff0c\u53ea\u663e\u793axx\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002<\/p>\n
C\u3001du --apparent-size\uff1a\u663e\u793a\u6587\u4ef6\u6216\u76ee\u5f55\u81ea\u8eab\u5927\u5c0f\uff0c\u800c\u4e0d\u662f\u5b83\u4eec\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\u3002\u6587\u4ef6\u6216\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u4e0e\u5b83\u4eec\u81ea\u8eab\u5927\u5c0f\u6709\u65f6\u5019\u5e76\u975e\u5b8c\u5168\u4e00\u81f4\uff1b\u8fd9\u79cd\u73b0\u8c61\u975elinux\u6240\u72ec\u6709\uff0cwindows\u91cc\u4e5f\u662f\u5982\u6b64\u3002\u6211\u4eec\u770b\u8fd9\u4e2a\u9009\u9879\u7684\u5e2e\u52a9\u6587\u6863\u7684\u89e3\u91ca\uff1aThe apparent size of a file is the number of bytes reported by `wc \u2013c` regular files ,or more generally, `ls \u2013l \u2013block-size=1` or `stat \u2013format=%s`.For example, a file containing the word `zoo` with no newline would, of course, have an apparent size of 3. Such a small file may require anywhere from 0 to 16 kib or more of disk space, depending on the type and configuration of the file system on which the file resides.<\/p>\n
\u8fd9\u6bb5\u8bdd\u7ed9\u51fa\u4e86\u6587\u4ef6\u6216\u76ee\u5f55\u81ea\u8eab\u5927\u5c0f\u4e0e\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\u7684\u533a\u522b\u3002\u4ed6\u4e0b\u9762\u4e3e\u51fa\u4e86\u4e00\u4e2a\u66f4\u52a0\u5938\u5f20\u7684\u4f8b\u5b50\uff0c\u8fd9\u91cc\u5c31\u4e0d\u628a\u5b83\u5199\u51fa\u6765\u4e86\u3002\u6211\u4eec\u77e5\u9053\u4e86\uff1awc\u6216ls --block-size\u663e\u793a\u7684\u662f\u5176\u81ea\u8eab\u5927\u5c0f\uff0c\u800cdu\u7ed9\u51fa\u7684\u5219\u662f\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u3002<\/p>\n
<\/p>\n
D\u3001du -c\uff1a\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u4e0d\u4ec5\u663e\u793a\u51e0\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u5404\u81ea\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\uff0c\u8fd8\u7edf\u8ba1\u5b83\u4eec\u7684\u603b\u548c\u3002<\/p>\n
\u5982\u56fe\u6240\u793a\uff0c\u52a0\u4e0a-c\u9009\u9879\u540e\uff0cdu\u4e0d\u4ec5\u663e\u793a\u4e24\u4e2a\u76ee\u5f55\u5404\u81ea\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\uff0c\u8fd8\u5728\u6700\u540e\u4e00\u884c\u7edf\u8ba1\u5b83\u4eec\u7684\u603b\u548c\u3002<\/p>\n
E\u3001du -l\uff1a\u8fd9\u4e2a\u9009\u9879\u4e3b\u8981\u662f\u9488\u5bf9\u786c\u94fe\u63a5\u3002\u5728\u7edf\u8ba1\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u5927\u5c0f\u65f6\uff0c-l\u9009\u9879\u4f1a\u628a\u786c\u94fe\u63a5\u4e5f\u7edf\u8ba1\u8fdb\u6765\u3002\u5e2e\u52a9\u6587\u6863\u662f\u8fd9\u6837\u89e3\u91ca\u7684\uff1a<\/p>\n
\nCount the size of all files,even if they have appeared already(as a hard link)\u3002<\/p>\n<\/blockquote>\n
<\/p>\n
\u6211\u4eec\u5728demo\u76ee\u5f55\u4e0b\u5efa\u7acb\u4e00\u4e2a\u786c\u94fe\u63a5\uff0c\u6307\u5411\u672c\u76ee\u5f55\u4e0b\u7684\u4e00\u4e2a\u6587\u4ef6\u3002\u4e0d\u4f7f\u7528-l\u9009\u9879\u65f6\uff0cdu\u53d1\u73b0\u786c\u94fe\u63a5\u6307\u5411\u672c\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c\u4e8e\u662f\u81ea\u52a8\u5ffd\u7565\u8be5\u94fe\u63a5\u6587\u4ef6\uff0c\u4ee5\u514d\u9020\u6210\u91cd\u590d\u7edf\u8ba1\uff1b\u4f7f\u7528-l\u9009\u9879\uff0cdu\u624d\u4f1a\u628a\u786c\u94fe\u63a5\u6587\u4ef6\u4e5f\u7edf\u8ba1\u8fdb\u6765\u3002<\/p>\n
\u3000\u3000 F\u3001du -L\uff1a\u8fd9\u4e2a\u9009\u9879\u4e3b\u8981\u662f\u9488\u5bf9\u7b26\u53f7\u94fe\u63a5\u3002\u5b83\u4f1a\u628a\u7b26\u53f7\u94fe\u63a5\u6240\u6307\u5411\u7684\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u5927\u5c0f\u4e5f\u7edf\u8ba1\u8fdb\u6765\u3002\u5e2e\u52a9\u6587\u6863\u662f\u8fd9\u6837\u89e3\u91ca\u7684\uff1a<\/p>\n
\nDereference symbolic links(show the disk space used by the file or directory that the link points to instead of the space used by the link)\u3002<\/p>\n<\/blockquote>\n
<\/p>\n
\u6211\u4eec\u5728demo3\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u7b26\u53f7\u94fe\u63a5\uff0c\u6307\u5411\u672c\u76ee\u5f55\u4e0b\u7684\u4e00\u4e2a\u6587\u4ef6\u3002\u6211\u4eec\u770b\u5230\u4e0a\u9762\u56fe\u7247\u4e2d\u663e\u793a\u7684\u64cd\u4f5c\u7ed3\u679c\uff0c\u5f53\u4f7f\u7528-L\u9009\u9879\u65f6\uff0cdu\u4f1a\u628a\u7b26\u53f7\u94fe\u63a5\u6240\u6307\u5411\u7684\u6587\u4ef6\u7684\u5927\u5c0f\u4e5f\u7edf\u8ba1\u5230\u76ee\u5f55\u91cc\u6765\u3002<\/p>\n
\u3000\u3000\u53e6\u5916\u6211\u4eec\u770bdu -lh\u7684\u7ed3\u679c\uff0c\u4e0edu -h\u76f8\u540c\uff0c\u597d\u50cf\u6ca1\u6709\u7edf\u8ba1\u51fa\u7b26\u53f7\u94fe\u63a5\u7684\u5927\u5c0f\uff1b\u5176\u5b9e\u5e76\u975e\u5982\u6b64\u3002\u4ece\u5b9e\u9645\u64cd\u4f5c\u6765\u770b\uff0c\u7b26\u53f7\u94fe\u63a5\u672c\u8eab\u4f3c\u4e4e\u5e76\u4e0d\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\uff0c\u6240\u4ee5\u624d\u51fa\u73b0\u4e0a\u8ff0\u60c5\u51b5\u3002<\/p>\n
\u3000\u3000\u6700\u540e\uff0cdu\u547d\u4ee4\u5728\u7edf\u8ba1\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u65f6\uff0c\u9ed8\u8ba4\u4e0d\u7edf\u8ba1\u94fe\u63a5\u6587\u4ef6\uff08\u65e0\u8bba\u662f\u786c\u94fe\u63a5\u6216\u662f\u7b26\u53f7\u94fe\u63a5\uff09\uff0c\u6240\u4ee5\u8981\u7528-l\u548c-L\u9009\u9879\u7279\u5730\u6307\u51fa\u6765\uff1b\u6b64\u5916\uff0cdu\u547d\u4ee4\u9ed8\u8ba4\u4e0d\u663e\u793a\u76ee\u5f55\u4e0b\u6587\u4ef6\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u4fe1\u606f\uff0c\u4f46\u662f\u5374\u9ed8\u8ba4\u663e\u793a\u5176\u4e0b\u5b50\u76ee\u5f55\u6240\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u7684\u4fe1\u606f\u3002\u602a\u54c9\u3002<\/p>\n
\ndu -sh : \u67e5\u770b\u5f53\u524d\u76ee\u5f55\u603b\u5171\u5360\u7684\u5bb9\u91cf\u3002\u800c\u4e0d\u5355\u72ec\u5217\u51fa\u5404\u5b50\u9879\u5360\u7528\u7684\u5bb9\u91cf <\/p>\n
du -lh --max-depth=1 : \u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u4e00\u7ea7\u5b50\u6587\u4ef6\u548c\u5b50\u76ee\u5f55\u5360\u7528\u7684\u78c1\u76d8\u5bb9\u91cf\u3002<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"linux\u6839\u76ee\u5f55\u6ee1\u4e86\uff0c\u600e\u6837\u5feb\u901f\u67e5\u770b\u662f\u54ea\u4e2a\u6587\u4ef6\u5360\u7528\u7a7a\u95f4\u5927linux\u67e5\u770b\u6839\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u5939\u5927\u5c0f\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a\t\t\t1\u3001\u8fdb\u5165\u6839\u76ee\u5f55\uff1acd\/\t\t\t2...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8048"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8048"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8048\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}