{"id":293383,"date":"2024-10-03T04:03:21","date_gmt":"2024-10-02T20:03:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/srtjlxtzdmld.html"},"modified":"2024-10-03T04:03:21","modified_gmt":"2024-10-02T20:03:21","slug":"srtjlxtzdmld","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/srtjlxtzdmld.html","title":{"rendered":"\u6df1\u5165\u63a2\u7a76 Linux \u7cfb\u7edf\u4e2d du \u547d\u4ee4\u7684\u6e90\u4ee3\u7801\u53ca\u5de5\u4f5c\u673a\u5236"},"content":{"rendered":"

\u5404\u4f4d\u597d\uff0c\u4eca\u5929\u6211\u4eec\u63a2\u8ba8Linux<\/a>\u7cfb\u7edf\u4e2d\u4e00\u6b3e\u6781\u4e3a\u5b9e\u7528\u7684\u5de5\u5177\u2014\u2014du\u547d\u4ee4<\/a>\u3002du\u547d\u4ee4\u5e76\u975e\u88c5\u9970\u6027\u529f\u80fd\uff0c\u800c\u662f\u771f\u6b63\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u5de5\u5177\u3002\u7b80\u79f0du\uff0c\u5168\u79f0\u4e3adiskusage\uff0c\u5373\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u67e5\u770b\u5668\u3002\u4f7f\u7528du\u547d\u4ee4\uff0c\u53ef\u8fc5\u901f\u4e86\u89e3\u7279\u5b9a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u78c1\u76d8\u7a7a\u95f4\u5360\u7528\u60c5\u51b5\uff0c\u529f\u80fd\u76f8\u5f53\u5353\u8d8a\u3002<\/p>\n

\u4eca\u5929\uff0c\u6211\u4eec\u7684\u76ee\u7684\u4e0d\u4ec5\u662f\u4f7f\u7528\u8be5\u547d\u4ee4\uff0c\u66f4\u662f\u8981\u6d1e\u6089\u5176\u6e90\u4ee3\u7801\uff0c\u63a2\u7a76\u5176\u5de5\u4f5c\u673a\u5236\u3002\u4ee5\u4f7f\u7528`du`\u547d\u4ee4\u67e5\u770b\u76ee\u5f55\u5bb9\u91cf\u4e3a\u4f8b\uff0c\u5c4f\u5e55\u4e0a\u6570\u5b57\u7684\u751f\u6210\u8fc7\u7a0b\u53ca\u5176\u80cc\u540e\u7684\u903b\u8f91\u4f55\u5728\uff1f\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u63ed\u6653\u8fd9\u4e00\u5e55\u540e\u4e4b\u8ff7\u3002<\/p>\n

du\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5<\/b><\/p>\n

\u7406\u89e3du\u547d\u4ee4\u7684\u64cd\u4f5c\u81f3\u5173\u91cd\u8981\u3002\u6b64\u547d\u4ee4\u7684\u4f7f\u7528\u7b80\u4fbf\uff0c\u53ea\u9700\u5728\u7ec8\u7aef\u8f93\u5165`du`\uff0c\u5e76\u9644\u4e0a\u6240\u9700\u68c0\u67e5\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u82e5\u9700\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u7684\u4f53\u79ef\uff0c\u53ea\u9700\u952e\u5165`du.`\uff1b\u82e5\u9700\u68c0\u67e5\u7279\u5b9a\u6587\u4ef6\uff0c\u5982`example.txt`\uff0c\u5219\u8f93\u5165`duexample.txt`\u3002\u64cd\u4f5c\u7b80\u4fbf\u6613\u61c2\u3002<\/p>\n

\u7136\u800c\uff0cdu\u547d\u4ee4\u62e5\u6709\u4f17\u591a\u53ef\u5e94\u7528\u53c2\u6570\u3002\u4f8b\u5982\uff0c`-h`\u9009\u9879\u80fd\u5b9e\u73b0\u4eba\u6027\u5316\u8f93\u51fa\uff0c\u81ea\u52a8\u9002\u5e94\u5355\u4f4d\u5982KB\u3001MB\u3001GB\u3002`-s`\u53c2\u6570\u5219\u4ec5\u5c55\u793a\u603b\u4f53\u79ef\uff0c\u4e0d\u7ec6\u5206\u81f3\u5404\u4e2a\u5b50\u76ee\u5f55\u3002\u5c3d\u7ba1\u8fd9\u4e9b\u53c2\u6570\u770b\u4f3c\u666e\u901a\uff0c\u5b9e\u9645\u8fd0\u7528\u4e2d\u5374\u663e\u8457\u63d0\u5347\u6548\u7387\u3002<\/p>\n

linuxdu\u547d\u4ee4_linux du\u547d\u4ee4 \u6e90\u7801_linuxdu<\/p>\n

du\u547d\u4ee4\u7684\u6e90\u7801\u7ed3\u6784<\/b><\/p>\n

\u638c\u63e1du\u547d\u4ee4\u7684\u4f7f\u7528\u540e\uff0c\u6211\u4eec\u5373\u5c06\u8e0f\u5165\u5176\u6e90\u4ee3\u7801\u7684\u63a2\u67e5\u9886\u57df\u3002du\u547d\u4ee4\u7684\u6e90\u4ee3\u7801\u7ed3\u6784\u76f8\u5bf9\u7b80\u5355\uff0c\u6838\u5fc3\u7531\u82e5\u5e72\u5173\u952e\u51fd\u6570\u6784\u6210\u3002\u9996\u5148\u805a\u7126\u4e8e\u5176\u4e3b\u51fd\u6570`main`\uff0c\u8be5\u51fd\u6570\u4e3b\u8981\u8d1f\u8d23\u89e3\u6790\u6307\u4ee4\u884c\u53c2\u6570\uff0c\u8fdb\u800c\u8c03\u7528\u4f5c\u4e1a\u51fd\u6570\u4ee5\u5b9e\u73b0\u5177\u4f53\u529f\u80fd\u3002<\/p>\n

\u5728`main`\u51fd\u6570\u4e2d\uff0c\u5b58\u5728\u5927\u91cf\u5e38\u89c4\u7684\u53c2\u6570\u89e3\u6790\u903b\u8f91\uff0c\u5176\u4e2d`getopt`\u51fd\u6570\u7528\u4e8e\u89e3\u6790\u547d\u4ee4\u884c\u9009\u9879\u3002\u968f\u540e\uff0c\u4f9d\u636e\u4e0d\u540c\u7684\u9009\u9879\uff0c`main`\u51fd\u6570\u5c06\u6267\u884c\u76f8\u5e94\u7684\u5b50\u51fd\u6570\u3002\u4f8b\u5982\uff0c\u542f\u7528`-s`\u9009\u9879\u65f6\uff0c`main`\u51fd\u6570\u5c06\u6267\u884c`du_summarize`\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4e3b\u8981\u8ba1\u7b97\u603b\u4f53\u79ef\u3002<\/p>\n

linuxdu\u547d\u4ee4_linux du\u547d\u4ee4 \u6e90\u7801_linuxdu<\/p>\n

du\u547d\u4ee4\u7684\u6838\u5fc3\u903b\u8f91<\/b><\/p>\n

\u63a2\u7a76du\u547d\u4ee4\u7684\u6838\u5fc3\u673a\u5236\u3002\u6b64\u547d\u4ee4\u7684\u8fd0\u4f5c\u903b\u8f91\u76f8\u5bf9\u76f4\u89c2linux du\u547d\u4ee4 \u6e90\u7801<\/strong>\uff0c\u6d89\u53ca\u5bf9\u76ee\u5f55\u6811\u7ed3\u6784\u7684\u9012\u5f52\u904d\u5386linux du\u547d\u4ee4 \u6e90\u7801<\/strong>\uff0c\u4ee5\u4f30\u7b97\u6bcf\u4e2a\u6587\u4ef6\u53ca\u76ee\u5f55\u7684\u4f53\u79ef\u3002\u6838\u5fc3\u5904\u7406\u7531`du_recurse`\u51fd\u6570\u5b9e\u73b0\u3002\u8be5\u51fd\u6570\u6267\u884c\u671f\u95f4\uff0c\u6d89\u53ca\u591a\u79cd\u5bf9\u6587\u4ef6\u7cfb\u7edf\u7684\u64cd\u4f5c\uff0c\u5305\u62ec`opendir`\u3001`readdir`\u3001`stat`\u7b49\u51fd\u6570\u3002<\/p>\n

`du_recurse`\u51fd\u6570\u542f\u52a8\u4e8e\u76ee\u5f55\u6253\u5f00\uff0c\u5e76\u9010\u4e2a\u8bfb\u53d6\u5176\u4e2d\u7684\u6240\u6709\u9879\u3002\u5bf9\u6bcf\u4e00\u9879\uff0c\u8c03\u7528`stat`\u4ee5\u6444\u53d6\u5176\u5c5e\u6027\uff0c\u4f8b\u5982\u6587\u4ef6\u5c3a\u5bf8\u3002\u82e5\u8be5\u9879\u4ee3\u8868\u5b50\u76ee\u5f55\uff0c`du_recurse`\u5c06\u81ea\u6211\u9012\u5f52\uff0c\u6df1\u6316\u8be5\u5b50\u76ee\u5f55\u3002\u6b64\u9012\u5f52\u8fc7\u7a0b\u6301\u7eed\u8fdb\u884c\uff0c\u76f4\u81f3\u76ee\u5f55\u6811\u5b8c\u5168\u904d\u5386\u3002<\/p>\n

linuxdu_linux du\u547d\u4ee4 \u6e90\u7801_linuxdu\u547d\u4ee4<\/p>\n

du\u547d\u4ee4\u7684\u4f18\u5316\u6280\u5de7<\/b><\/p>\n

\u5c3d\u7ba1du\u547d\u4ee4\u7684\u6838\u5fc3\u7406\u5ff5\u7b80\u5355\u6613\u61c2\uff0c\u4f46\u5728\u5177\u4f53\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\uff0c\u6027\u80fd\u74f6\u9888\u53ef\u80fd\u6210\u4e3a\u6311\u6218\u3002\u4f8b\u5982\uff0c\u5f53\u68c0\u67e5\u5e9e\u5927\u7684\u76ee\u5f55\u65f6\uff0c\u8be5\u547d\u4ee4\u7684\u8fd0\u884c\u901f\u5ea6\u53ef\u80fd\u53d8\u6162\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u91c7\u7528\u4f18\u5316\u7b56\u7565\u6210\u4e3a\u5fc5\u8981\u3002<\/p>\n

\u91c7\u7528`-x`\u9009\u9879\u53ef\u4ee4`du`\u6307\u4ee4\u4e13\u6ce8\u4e8e\u4f30\u7b97\u73b0\u6709\u6587\u4ef6\u7cfb\u7edf\u5bb9\u91cf\uff0c\u820d\u5f03\u5176\u4ed6\u6587\u4ef6\u7cfb\u7edf\u8003\u91cf\uff0c\u4ece\u800c\u663e\u8457\u964d\u4f4e\u8ba1\u7b97\u8017\u65f6\u5e76\u63d0\u5347\u6548\u7387\u3002\u6b64\u5916\uff0c\u9009\u7528`-P`\u9009\u9879\u5219\u53ef\u542f\u7528\u6307\u4ee4\u5728\u591a\u4e2a\u76ee\u5f55\u95f4\u5e76\u884c\u64cd\u4f5c\uff0c\u8fdb\u800c\u63d0\u5347\u6574\u4f53\u5904\u7406\u6027\u80fd\u3002<\/p>\n

linuxdu_linuxdu\u547d\u4ee4_linux du\u547d\u4ee4 \u6e90\u7801<\/p>\n

du\u547d\u4ee4\u7684\u5e38\u89c1\u95ee\u9898<\/b><\/p>\n

\u64cd\u4f5cdu\u547d\u4ee4\u65f6red hat linux\uff0c\u7528\u6237\u53ef\u80fd\u906d\u9047\u4e00\u4e9b\u5e38\u89c4\u96be\u9898\u3002\u4f8b\u5982\uff0cdu\u547d\u4ee4\u663e\u793a\u7684\u6587\u4ef6\u91cf\u4e0e\u5b9e\u9645\u503c\u4e0d\u7b26\uff0c\u539f\u56e0\u53ef\u80fd\u5728\u4e8e\u6587\u4ef6\u7cfb\u7edf\u5b58\u5728\u788e\u7247\u6216\u6587\u4ef6\u5b9e\u65bd\u538b\u7f29\u3002\u4e3a\u83b7\u53d6\u51c6\u786e\u6587\u4ef6\u91cf\u4fe1\u606f\uff0c\u53ef\u5e94\u7528`-b`\u9009\u9879\uff0c\u8be5\u9009\u9879\u6307\u793adu\u547d\u4ee4\u5c55\u793a\u6587\u4ef6\u7684\u5b9e\u9645\u7269\u7406\u5927\u5c0f\u800c\u975e\u7cfb\u7edf\u8bb0\u5f55\u7684\u5927\u5c0f\u3002<\/p>\n

\u6b64\u5916\uff0cdu\u547d\u4ee4\u6709\u65f6\u6267\u884c\u7f13\u6162\u6216\u505c\u6ede\uff0c\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u9501\u5b9a\uff0c\u6216\u6587\u4ef6\u7cfb\u7edf\u6545\u969c\u3002\u5728\u6b64\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u52a0\u5165`-c`\u9009\u9879\uff0c\u53ef\u4f7fdu\u547d\u4ee4\u5728\u906d\u9047\u9519\u8bef\u65f6\u7ee7\u7eed\u6267\u884c\u800c\u975e\u4e2d\u65ad\u3002<\/p>\n

du\u547d\u4ee4\u7684\u672a\u6765\u5c55\u671b<\/b><\/p>\n

\u6280\u672f\u8fdb\u6b65\u63a8\u52a8\u4e0b\uff0cdu\u547d\u4ee4\u6301\u7eed\u6f14\u8fdb\u3002\u672a\u6765\u5c55\u671b\u4e2d\uff0c\u9884\u671f\u5c06\u5f15\u5165\u65b0\u589e\u529f\u80fd\u4e0e\u4f18\u5316\u3002\u4f8b\u5982\uff0c\u8be5\u547d\u4ee4\u53ef\u80fd\u6269\u5c55\u81f3\u652f\u6301\u66f4\u591a\u6587\u4ef6\u7cfb\u7edf\uff0c\u5e76\u4e30\u5bcc\u7edf\u8ba1\u5206\u6790\u5185\u5bb9\u3002\u4f34\u968f\u4e91\u8ba1\u7b97\u4e0e\u5927\u6570\u636e\u6f6e\u6d41\uff0cdu\u547d\u4ee4\u6709\u671b\u5b9e\u73b0\u667a\u80fd\u5316\uff0c\u81ea\u52a8\u5206\u6790\u5e76\u4f18\u5316\u78c1\u76d8\u8d44\u6e90\u3002<\/p>\n

\u603b\u7ed3\u4e0e\u601d\u8003<\/b><\/p>\n

\u4eca\u65e5\uff0c\u6211\u4eec\u7ec6\u81f4\u5256\u6790\u4e86du\u547d\u4ee4\u7684\u6e90\u4ee3\u7801\uff0c\u6d1e\u5bdf\u4e86\u5176\u57fa\u672c\u64cd\u4f5c\u3001\u6838\u5fc3\u67b6\u6784\u3001\u4f18\u5316\u7b56\u7565\u53ca\u5e38\u89c1\u95ee\u9898\u3002\u6b64\u6b21\u5206\u6790\u4f7f\u6211\u4eec\u4e0d\u4ec5\u638c\u63e1\u4e86du\u547d\u4ee4\u7684\u9ad8\u6548\u8fd0\u7528\uff0c\u4ea6\u5bf9Linux<\/a>\u7cfb\u7edf\u7684\u5e95\u5c42\u67b6\u6784\u6709\u4e86\u6df1\u5165\u8ba4\u8bc6\u3002<\/p>\n

\u5f53\u524d\uff0c\u672c\u60f3\u5c31du\u547d\u4ee4\u7684\u4f7f\u7528\u5f81\u8be2\u5404\u4f4d\uff1a\u5728\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\uff0c\u60a8\u662f\u5426\u9047\u5230\u8fc7\u5f15\u4eba\u5165\u80dc\u6216\u96be\u9898\uff1f\u5176\u89e3\u51b3\u7b56\u7565\u4f55\u5728\uff1f\u656c\u8bf7\u4e8e\u8bc4\u8bba\u533a\u4ea4\u6d41\u5fc3\u5f97\u4e0e\u89c1\u89e3\uff0c\u4ee5\u671f\u5171\u540c\u63d0\u5347\u6280\u80fd\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4eca\u5929\uff0c\u6211\u4eec\u7684\u76ee\u7684\u4e0d\u4ec5\u662f\u4f7f\u7528\u8be5\u547d\u4ee4\uff0c\u66f4\u662f\u8981\u6d1e\u6089\u5176\u6e90\u4ee3\u7801\uff0c\u63a2\u7a76\u5176\u5de5\u4f5c\u673a\u5236\u3002\u638c\u63e1du\u547d\u4ee4\u7684\u4f7f\u7528\u540e\uff0c\u6211\u4eec\u5373\u5c06\u8e0f\u5165\u5176\u6e90\u4ee3\u7801\u7684\u63a2\u67e5\u9886\u57df\u3002\u63a2\u7a76du\u547d\u4ee4\u7684\u6838\u5fc3\u673a\u5236\u3002\u8be5\u51fd\u6570\u6267\u884c\u671f\u95f4\uff0c\u6d89\u53ca\u591a\u79cd\u5bf9\u6587\u4ef6\u7cfb\u7edf\u7684\u64cd\u4f5c\uff0c\u5305\u62ec`opendir`\u3001`readdir`\u3001`stat`\u7b49\u51fd\u6570\u3002<\/p>\n","protected":false},"author":1,"featured_media":293384,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[3364,109,3366,3365,3367],"class_list":["post-293383","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-dml-5","tag-linux","tag-csjx","tag-mlhxx","tag-hxlj"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/293383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=293383"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/293383\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/293384"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=293383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=293383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=293383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}