{"id":254385,"date":"2022-10-17T09:38:57","date_gmt":"2022-10-17T01:38:57","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254385"},"modified":"2022-10-13T09:08:24","modified_gmt":"2022-10-13T01:08:24","slug":"what-busybox-usage","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/what-busybox-usage.html","title":{"rendered":"\u4ec0\u4e48\u662f BusyBox \u4ee5\u53ca\u5b83\u5728\u54ea\u91cc\u4f7f\u7528\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nBusyBox\u662f\u6253\u5305\u4e3a\u5355\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u6838\u5fc3 Unix \u5b9e\u7528\u7a0b\u5e8f\u7684\u96c6\u5408\u3002\u8fd9\u4f7f\u5176\u6210\u4e3a\u8d44\u6e90\u53d7\u9650\u73af\u5883\uff08\u4f8b\u5982\u5d4c\u5165\u5f0f\u8bbe\u5907\uff09\u7684\u7406\u60f3\u9009\u62e9\u3002\u5b8c\u6574\u7684\u53d1\u884c\u7248\u5305\u542b\u8fd1 400 \u4e2a\u6700\u5e38\u7528\u7684\u547d\u4ee4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

BusyBox \u662f\u5f00\u6e90\u7684\uff0c\u5e76\u5728 GPL \u4e0b\u83b7\u5f97\u8bb8\u53ef\u3002\u5b83\u521b\u5efa\u4e8e 1995 \u5e74\uff0c\u65e8\u5728\u4f7f\u53ef\u5f15\u5bfc\u7cfb\u7edf\u9002\u5408\u5355\u4e2a\u8f6f\u76d8\u3002\u5c06\u547d\u4ee4\u6346\u7ed1\u5230\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u53ef\u4ee5\u51cf\u5c11\u5f00\u9500\u5e76\u5141\u8bb8\u770b\u4f3c\u72ec\u7acb\u7684\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u7684\u4ee3\u7801\u5171\u4eab\u3002<\/p>\n

BusyBox \u5305\u62ec\u4ec0\u4e48\uff1f<\/strong><\/div>\n

BusyBox \u63d0\u4f9b\u4e86\u65e5\u5e38\u4fbf\u5229\u7684\u547d\u4ee4\uff0c\u8fd9\u4e9b\u547d\u4ee4\u5e38\u5e38\u8ba9\u4eba\u89c9\u5f97\u5b83\u4eec\u662f\u60a8\u7684 shell \u7684\u4e00\u90e8\u5206\u3002\u5c3d\u7ba1 userland \u5de5\u5177\u559c\u6b22ls\u5e76\u4e14cat\u65e0\u5904\u4e0d\u5728\uff0c\u4f46\u5b83\u4eec\u5b9e\u9645\u4e0a\u9a7b\u7559\u5728\u72ec\u7acb\u4e8e\u60a8\u7684 shell \u7684\u5355\u72ec\u5b9e\u7528\u7a0b\u5e8f\u5305\u4e2d\u3002\u8bb8\u591a Linux \u53d1\u884c\u7248\u901a\u8fc7 GNU \u63d0\u4f9b\u8fd9\u4e9b\u547d\u4ee4\uff0ccoreutils \u4f46\u5176\u4ed6\u53d1\u884c\u7248\u5219\u4f7f\u7528BusyBox\u3002<\/p>\n

\u8be5\u9879\u76ee\u7684\u5de5\u4f5c\u539f\u7406\u662f\u5c06\u719f\u6089\u7684\u547d\u4ee4\u540d\u79f0\u7b26\u53f7\u94fe\u63a5\/usr\/bin\u5230 BusyBox \u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u3002\u8be5\u53ef\u6267\u884c\u6587\u4ef6\u7136\u540e\u8c03\u7528\u4e0e\u4f5c\u4e3a\u5176\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f20\u9012\u7684\u540d\u79f0\u76f8\u5bf9\u5e94\u7684\u51fd\u6570\u3002<\/p>\n

\u4f7f\u7528 BusyBox\u547d\u4ee4mkdir\u8fd0\u884c <\/p>\n

\/usr\/bin\/busybox mkdir<\/pre>\n

\u4f7f\u7528 GNU Coreutils \u2013 \u547d\u4ee4mkdir\u8fd0\u884c<\/p>\n

\/usr\/bin\/mkdir<\/pre>\n<\/p>\n

\u60a8\u53ef\u4ee5\u900f\u660e\u5730\u4f7f\u7528\u7c7b\u4f3c\u7684\u547d\u4ee4mkdir\uff0cpasswd\uff0cps\uff0ctar\uff0c\u5e76\u4e14wget\u4e00\u65e6\u5b89\u88c5\u4e86BusyBox\u3002\u547d\u4ee4\u88ab\u5b9e\u73b0\u4e3a\u201c\u5c0f\u7a0b\u5e8f\u201d\uff0c\u5b83\u4eec\u88ab\u7ec4\u5408\u6210\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684 BusyBox \u53d1\u884c\u7248\u3002\u5168\u5957\u91cd\u91cf\u7ea6\u4e3a 1MB\u3002\u5c0f\u7a0b\u5e8f\u662f\u53ef\u79fb\u52a8\u7684\uff0c\u56e0\u6b64\u4e8c\u8fdb\u5236\u5927\u5c0f\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7f29\u5c0f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7busybox\u4e0d\u5e26\u53c2\u6570\u8fd0\u884c\u6765\u68c0\u67e5\u5b89\u88c5\u4e2d\u7684\u53ef\u7528\u5185\u5bb9\u3002<\/p>\n

\u7531\u4e8e BusyBox \u662f\u4e3a\u5fae\u578b\u53ef\u542f\u52a8\u7cfb\u7edf\u800c\u521b\u5efa\u7684\uff0c\u5b83\u6db5\u76d6\u4e86\u7528\u6237\u7a7a\u95f4\u4e2d\u542f\u52a8\u548c\u7ba1\u7406 POSIX \u7cfb\u7edf\u6240\u9700\u7684\u4e00\u5207\u3002\u8fd9\u6269\u5c55\u5230init\u80fd\u591f\u4f5c\u4e3a\u8fdb\u7a0b ID \u8fd0\u884c1\u5e76\u652f\u6301\u7cfb\u7edf\u670d\u52a1\u7684\u6700\u5c0f\u5b9e\u73b0\u3002\u60a8\u53ef\u4ee5\u91c7\u7528 BusyBox \u4f5c\u4e3a\u5e38\u89c4init\u6216systemd\u5b88\u62a4\u7a0b\u5e8f\u7684\u8f7b\u91cf\u7ea7\u66ff\u4ee3\u54c1\u3002<\/p>\n

\u7531\u4e8e BusyBox \u6709\u610f\u6700\u5c0f\u5316\uff0c\u5e76\u975e\u6bcf\u4e2a\u547d\u4ee4\u90fd\u5b9e\u73b0\u4e86\u5176 GNU \u5bf9\u5e94\u9879\u7684\u6240\u6709\u529f\u80fd\u3002\u5728\u4e0d\u5e38\u89c1\u7684\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\u4e00\u4e9b\u7f3a\u5931\u7684\u6807\u5fd7\u6216\u884c\u4e3a\u5dee\u5f02\u3002\u8fd9\u662f BusyBox \u6d41\u7ebf\u578b\u7279\u6027\u7684\u6743\u8861\u4e4b\u4e00\u3002<\/p>\n

BusyBox \u5728\u54ea\u91cc\u4f7f\u7528\uff1f<\/strong><\/div>\n

BusyBox \u53ef\u4ee5\u5728\u4efb\u4f55\u9700\u8981\u5173\u6ce8\u78c1\u76d8\u4f7f\u7528\u7684\u5730\u65b9\u627e\u5230\u3002\u5b83\u88ab\u8bf8\u5982 Alpine \u4e4b\u7c7b\u7684\u6700\u5c0f\u64cd\u4f5c\u7cfb\u7edf\u4ee5\u53ca\u5d4c\u5165\u5f0f\u8bbe\u5907\u548c\u79fb\u52a8\u5916\u58f3\u4e4b\u7c7b\u7684\u4e13\u95e8\u573a\u666f\u6240\u4f7f\u7528\u3002<\/p>\n

\u4e0d\u8fd0\u884c\u4f20\u7edf\u64cd\u4f5c\u7cfb\u7edf\u53d1\u884c\u7248\u7684 Unix \u884d\u751f\u8bbe\u5907\u5f88\u6709\u53ef\u80fd\u4f1a\u4f7f\u7528 BusyBox\u3002\u60a8\u53ef\u4ee5\u5728\u7f51\u7edc\u8def\u7531\u5668\u3001\u667a\u80fd\u7535\u89c6\u3001\u73b0\u4ee3\u6c7d\u8f66\u548c\u7269\u8054\u7f51\u8bbe\u5907\u4e0a\u627e\u5230\u5b83\u3002\u8fd9\u4e9b\u8bbe\u7f6e\u4e2d\u7684\u6bcf\u4e00\u4e2a\u90fd\u9700\u8981\u5728\u8d44\u6e90\u4e25\u91cd\u53d7\u9650\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u6838\u5fc3\u7528\u6237\u7a7a\u95f4\u5de5\u5177\u3002<\/p>\n

\u53d1\u9001\u5355\u4e2a\u591a\u5408\u4e00\u4e8c\u8fdb\u5236\u6587\u4ef6\u66f4\u6709\u6548\u3002\u5b83\u5141\u8bb8\u6240\u6709\u547d\u4ee4\u5171\u4eab\u516c\u5171\u4ee3\u7801\uff0c\u800c\u65e0\u9700\u5728\u78c1\u76d8\u4e0a\u5b58\u50a8\u72ec\u7acb\u5e93\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u5197\u4f59\u3002\u7531\u4e8e BusyBox \u63d0\u4f9b\u4e86\u4e0e\u5176\u4ed6\u5b9e\u73b0\u7684\u826f\u597d\u517c\u5bb9\u6027\uff0c\u5e76\u4e14\u5728 GPL \u4e0b\u83b7\u5f97\u8bb8\u53ef\uff0c\u56e0\u6b64\u5b83\u901a\u5e38\u662f\u9700\u8981\u4e00\u7ec4\u8f7b\u91cf\u7ea7\u5b9e\u7528\u7a0b\u5e8f\u7684\u73af\u5883\u7684\u9996\u9009\u3002<\/p>\n

\u5d4c\u5165\u5f0f\u8bbe\u5907\u7684\u4f9b\u5e94\u5546\u4e5f\u53d7\u76ca\u4e8e BusyBox \u7684\u6a21\u5757\u5316\u7279\u6027\u3002\u7269\u8054\u7f51\u4ea7\u54c1\u53ef\u80fd\u53ea\u9700\u8981\u5c11\u6570\u5173\u952e\u5b9e\u7528\u7a0b\u5e8f\u6765\u63d0\u4f9b\u5176\u529f\u80fd\u3002\u5206\u53d1\u4fee\u6539\u8fc7\u7684 BusyBox \u4e8c\u8fdb\u5236\u6587\u4ef6\u53ef\u4ee5\u91ca\u653e\u66f4\u591a KB \u7684\u78c1\u76d8\u7a7a\u95f4\uff0c\u8fd9\u53ef\u4ee5\u663e\u7740\u8282\u7701\u3002<\/p>\n

\u5982\u4f55\u8bd5\u7528 BusyBox<\/strong><\/div>\n

\u60a8\u53ef\u4ee5\u5728\u4e0d\u66ff\u6362\u5f53\u524d\u5b9e\u7528\u7a0b\u5e8f\u7684\u60c5\u51b5\u4e0b\u5b89\u88c5 BusyBox\u3002\u4f7f\u7528\u60a8\u7684\u5305\u7ba1\u7406\u5668\u6dfb\u52a0busybox\uff0c\u7136\u540e\u5c06\u60a8\u9009\u62e9\u7684\u547d\u4ee4\u9644\u52a0\u5230busybox\u4e8c\u8fdb\u5236\u6587\u4ef6\u4ee5\u8fd0\u884c\u5c0f\u7a0b\u5e8f\uff1a<\/p>\n

busybox mkdir test<\/pre>\n

\u8fd9\u786e\u4fdd\u5c06\u4f7f\u7528\u547d\u4ee4\u7684 BusyBox \u7248\u672c\u800c\u4e0d\u662f shell \u7684\u9ed8\u8ba4\u8def\u5f84\u4e2d\u7684\u7248\u672c\u3002<\/p>\n

\u53e6\u4e00\u79cd\u5c1d\u8bd5 BusyBox \u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u5176\u5b98\u65b9 Docker \u955c\u50cf\uff1a<\/p>\n

docker run -it --rm busybox<\/pre>\n

\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86 Docker\uff0c\u8fd9\u4f1a\u8ba9\u4f60\u8fdb\u5165 BusyBox \u7684 shell \u5b9e\u73b0\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u56fe\u50cf\u540d\u79f0\u540e\u6dfb\u52a0\u5b83\u6765\u8fd0\u884c\u7279\u5b9a\u547d\u4ee4\uff1a<\/p>\n

docker run -it --rm busybox mkdir demo<\/pre>\n

usyBox \u8fd8\u5177\u6709JavaScript \u6a21\u62df\u5668\uff0c\u53ef\u8ba9\u60a8\u5728 Web \u6d4f\u89c8\u5668\u4e2d\u8bd5\u7528\u8fd9\u4e9b\u5b9e\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u5728\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e0a\uff0c\u60a8\u4e0d\u80fd\u5b8c\u5168coreutils\u7528 BusyBox\u66ff\u6362\u3002\u7279\u5b9a\u4e8e\u53d1\u884c\u7248\u7684\u547d\u4ee4\u548c\u5305\u901a\u5e38\u662f\u786c\u8fde\u63a5\u7684\uff0c\u671f\u671bcoreutils\u5b9e\u7528\u7a0b\u5e8f\u53ef\u7528\u3002\u60a8\u7684\u53d1\u884c\u7248\u901a\u5e38\u4f1a\u62d2\u7edd\u5378\u8f7d\u6b64\u8f6f\u4ef6\u5305\uff0c\u56e0\u4e3a\u5982\u679cinit\u5220\u9664\u5b83\u53ef\u80fd\u4f1a\u4f7f\u7cfb\u7edf\u65e0\u6cd5\u8fd0\u884c\u3002<\/p>\n

\u5982\u679c\u60a8\u60f3\u4f9d\u8d56 BusyBox\uff0c\u6700\u597d\u4ece\u4f7f\u7528\u5b83\u7684\u53d1\u884c\u7248\u5f00\u59cb\uff0c\u7136\u540e\u5c06\u5176\u4ed6\u8f6f\u4ef6\u653e\u5728\u4e0a\u9762\u3002coreutils\u5f53\u60a8\u9700\u8981\u68c0\u67e5\u5c0f\u7a0b\u5e8f\u5728\u7279\u5b9a\u573a\u666f\u4e2d\u7684\u54cd\u5e94\u65b9\u5f0f\u65f6\uff0c\u5982\u4e0a\u6240\u793a\u6dfb\u52a0 BusyBox\u6548\u679c\u5f88\u597d\u3002<\/p>\n

\u7ed3\u8bba<\/strong><\/div>\n

usyBox \u662f\u6253\u5305\u4e3a\u5355\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u7528\u6237\u7ea7 UNIX \u5b9e\u7528\u7a0b\u5e8f\u7684\u8f7b\u91cf\u7ea7\u5b9e\u73b0\u3002\u60a8\u53ef\u4ee5\u5c06\u5b83\u4e0e Linux \u5185\u6838\u7ed3\u5408\u8d77\u6765\uff0c\u4ee5\u521b\u5efa\u4e00\u4e2a\u6ca1\u6709\u5176\u4ed6\u4f9d\u8d56\u9879\u7684\u6b63\u5e38\u8fd0\u884c\u7684\u7cfb\u7edf\u3002<\/p>\n

BusyBox \u9488\u5bf9\u7a7a\u95f4\u53d7\u9650\u7684\u73af\u5883\u8fdb\u884c\u4e86\u4f18\u5316\u3002\u8fd9\u4f7f\u5176\u6210\u4e3a\u7269\u8054\u7f51\u8bbe\u5907\u7b49\u5d4c\u5165\u5f0f\u4ea7\u54c1\u7684\u7406\u60f3\u9009\u62e9\u3002\u60a8\u53ef\u80fd\u8fd8\u4f1a\u53d1\u73b0 BusyBox \u5b89\u88c5\u5728\u6700\u5c0f\u4f46\u901a\u7528\u7684 Linux \u53d1\u884c\u7248\u4e0a\uff0c\u4f8b\u5982 Alpine Linux\u3002<\/p>\n

\u65e0\u8bba\u60a8\u4f7f\u7528\u7684\u662f BusyBox \u8fd8\u662f GNU Coreutils\uff0c\u60a8\u719f\u6089\u7684\u547d\u4ee4\u901a\u5e38\u90fd\u201c\u9002\u7528\u201d\u4e8e\u4efb\u4e00\u5b9e\u73b0\u3002\u4efb\u4f55\u51fa\u73b0\u7684\u95ee\u9898\u901a\u5e38\u90fd\u662f\u7531\u4e8e BusyBox \u6ca1\u6709\u5b9e\u73b0\u67d0\u4e2a\u7f55\u89c1\u7684\u6807\u5fd7\u6216\u914d\u7f6e\u9009\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

BusyBox \u662f\u5f00\u6e90\u7684\uff0c\u5e76\u5728 GPL \u4e0b\u83b7\u5f97\u8bb8\u53ef\u3002\u5b83\u521b\u5efa\u4e8e 1995 \u5e74\uff0c\u65e8\u5728\u4f7f\u53ef\u5f15\u5bfc\u7cfb\u7edf\u9002\u5408\u5355\u4e2a\u8f6f\u76d8\u3002\u5c06\u547d […]<\/p>\n","protected":false},"author":310,"featured_media":254393,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254385","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254385","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\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254385"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254385\/revisions"}],"predecessor-version":[{"id":254395,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254385\/revisions\/254395"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/254393"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}