{"id":279813,"date":"2023-08-09T04:04:31","date_gmt":"2023-08-08T20:04:31","guid":{"rendered":"https:\/\/lrxjmw.cn\/lwjmsfnljm.html"},"modified":"2023-08-09T04:04:31","modified_gmt":"2023-08-08T20:04:31","slug":"lwjmsfnljm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lwjmsfnljm.html","title":{"rendered":"Linux\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u4f60\u4e86\u89e3\u5417\uff1f"},"content":{"rendered":"

\u5c0f\u7f16\u6765\u7ed9\u5927\u5bb6\u79d1\u666e\u4e00\u4e0b\u5173\u4e8eLinux<\/a>\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u77e5\u8bc6\uff01\u4f60\u77e5\u9053\u5417linux\u6587\u4ef6\u63cf\u8ff0\u7b26<\/strong>\uff0c\u6587\u4ef6\u63cf\u8ff0\u7b26\u662fLinux\u7cfb\u7edf<\/a>\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u5b83\u626e\u6f14\u7740\u8fde\u63a5\u5e94\u7528\u7a0b\u5e8f\u548c\u6587\u4ef6\u7684\u6865\u6881\u3002\u4e0b\u9762\u5c31\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u4e86\u89e3\u4e00\u4e0b\u5427\uff01<\/p>\n

1.\u4ec0\u4e48\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1f<\/p>\n

\u5728Linux\u7cfb\u7edf\u4e2dlinux\u6587\u4ef6\u63cf\u8ff0\u7b26<\/strong>\uff0c\u6bcf\u4e2a\u6253\u5f00\u7684\u6587\u4ef6\u90fd\u4f1a\u88ab\u5185\u6838\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u8fd9\u4e2a\u6807\u8bc6\u7b26\u5c31\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\u5b83\u662f\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\uff0c\u7528\u6765\u533a\u5206\u4e0d\u540c\u7684\u6587\u4ef6\u3002<\/p>\n

2.\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5206\u7c7b<\/p>\n

\u6587\u4ef6\u63cf\u8ff0\u7b26\u53ef\u4ee5\u5206\u4e3a\u4e09\u7c7b\uff1a\u6807\u51c6\u8f93\u5165\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u3002\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u7740\u6570\u5b570\u30011\u548c2\u3002<\/p>\n

3.\u5982\u4f55\u4f7f\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1f<\/p>\n

\u5c0f\u7f16\u7ed9\u5927\u5bb6\u4e3e\u4e2a\u4f8b\u5b50linux makefile\uff0c\u5047\u8bbe\u6211\u4eec\u8981\u5c06\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u7684\u5185\u5bb9\u8f93\u51fa\u5230\u7ec8\u7aef\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4<\/a>\uff1a<\/p>\n

\n

\n   cat file.txt\n   <\/pre>\n<\/p>\n

\u5728\u8fd9\u4e2a\u547d\u4ee4\u4e2d\uff0ccat\u547d\u4ee4\u4f1a\u6253\u5f00file.txt\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5185\u5bb9\u8f93\u51fa\u5230\u6807\u51c6\u8f93\u51fa\uff08\u4e5f\u5c31\u662f\u7ec8\u7aef\uff09\u3002<\/p>\n

4.\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u91cd\u5b9a\u5411<\/p>\n

\u6709\u65f6\u5019\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5c06\u8f93\u51fa\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u6216\u8005\u5c06\u9519\u8bef\u4fe1\u606f\u8f93\u51fa\u5230\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\u4e2d\u3002\u8fd9\u65f6\u5c31\u53ef\u4ee5\u4f7f\u7528\u91cd\u5b9a\u5411\u6765\u5b9e\u73b0\u3002<\/p>\n

-\u5c06\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef6\uff1a<\/p>\n

\n

\n     command > file.txt\n     <\/pre>\n<\/p>\n

-\u5c06\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef6\uff1a<\/p>\n

\n

\n     command 2> error.log\n     <\/pre>\n<\/p>\n

\u63cf\u8ff0\u7b26\u6587\u4ef6\u662f\u4ec0\u4e48_\u63cf\u8ff0\u7b26\u6587\u4ef6\u5220\u4e0d\u4e86_linux\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n

-\u5c06\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u90fd\u91cd\u5b9a\u5411\u5230\u540c\u4e00\u4e2a\u6587\u4ef6\uff1a<\/p>\n

\n

\n     command > output.txt 2>&1\n     <\/pre>\n<\/p>\n

5.\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5173\u95ed<\/p>\n

\u5f53\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e0d\u518d\u9700\u8981\u4f7f\u7528\u67d0\u4e2a\u6587\u4ef6\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26\u6765\u91ca\u653e\u7cfb\u7edf\u8d44\u6e90\u3002<\/p>\n

-\u4f7f\u7528close()\u51fd\u6570\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1a<\/p>\n

linux\u6587\u4ef6\u63cf\u8ff0\u7b26_\u63cf\u8ff0\u7b26\u6587\u4ef6\u662f\u4ec0\u4e48_\u63cf\u8ff0\u7b26\u6587\u4ef6\u5220\u4e0d\u4e86<\/p>\n

\n

\n     close(fd);\n     <\/pre>\n<\/p>\n

6.\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u9650\u5236<\/p>\n

Linux\u7cfb\u7edf\u5bf9\u4e8e\u6bcf\u4e2a\u8fdb\u7a0b\u6240\u80fd\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u91cf\u6709\u4e00\u5b9a\u7684\u9650\u5236\u3002\u53ef\u4ee5\u4f7f\u7528ulimit\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u9650\u5236\u3002<\/p>\n

-\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\uff1a<\/p>\n

\n

\n     ulimit -n\n     <\/pre>\n<\/p>\n

\u63cf\u8ff0\u7b26\u6587\u4ef6\u662f\u4ec0\u4e48_\u63cf\u8ff0\u7b26\u6587\u4ef6\u5220\u4e0d\u4e86_linux\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n

7.\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u7ee7\u627f<\/p>\n

\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u521b\u5efa\u5b50\u8fdb\u7a0b\u65f6\uff0c\u5b50\u8fdb\u7a0b\u4f1a\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\u8fd9\u610f\u5473\u7740\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u7236\u8fdb\u7a0b\u6253\u5f00\u8fc7\u7684\u6587\u4ef6\u3002<\/p>\n

8.\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e0e\u7f51\u7edc\u7f16\u7a0b<\/p>\n

\u5728\u7f51\u7edc\u7f16\u7a0b\u4e2d\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u4f7f\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\u6765\u8fdb\u884c\u5957\u63a5\u5b57\u64cd\u4f5c\u3002\u901a\u8fc7\u5957\u63a5\u5b57\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u7f51\u7edc\u901a\u4fe1\uff0c\u4f8b\u5982\u5efa\u7acbTCP\u8fde\u63a5\u3001\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u7b49\u3002<\/p>\n

\u5c0f\u7f16\u76f8\u4fe1\u901a\u8fc7\u8fd9\u7bc7\u6587\u7ae0\u7ea2\u5e3d\u5b50linux\uff0c\u5927\u5bb6\u5bf9Linux\u6587\u4ef6\u63cf\u8ff0\u7b26\u6709\u4e86\u66f4\u6df1\u5165\u7684\u4e86\u89e3\u3002\u5e0c\u671b\u8fd9\u4e9b\u77e5\u8bc6\u5bf9\u4f60\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\u6709\u6240\u5e2e\u52a9\uff01\u5982\u679c\u8fd8\u6709\u5176\u4ed6\u95ee\u9898\uff0c\u6b22\u8fce\u7559\u8a00\u8ba8\u8bba\u54e6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4ec0\u4e48\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1f\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6253\u5f00\u7684\u6587\u4ef6\u90fd\u4f1a\u88ab\u5185\u6838\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u8fd9\u4e2a\u6807\u8bc6\u7b26\u5c31\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5206\u7c7b\u5982\u4f55\u4f7f\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1f\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u91cd\u5b9a\u5411\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5173\u95ed-\u4f7f\u7528close()\u51fd\u6570\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1a\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u9650\u5236-\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\uff1a\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u7ee7\u627f\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e0e\u7f51\u7edc\u7f16\u7a0b\u5728\u7f51\u7edc\u7f16\u7a0b\u4e2d\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u4f7f\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\u6765\u8fdb\u884c\u5957\u63a5\u5b57\u64cd\u4f5c\u3002<\/p>\n","protected":false},"author":1,"featured_media":279814,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-279813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/279813","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=279813"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/279813\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/279814"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=279813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=279813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=279813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}