{"id":3326,"date":"2018-04-04T23:07:46","date_gmt":"2018-04-04T15:07:46","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3326"},"modified":"2025-01-26T16:39:09","modified_gmt":"2025-01-26T08:39:09","slug":"linux%e7%9a%84%e4%ba%94%e4%b8%aa%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/jishu\/fuwuqi\/linux%e7%9a%84%e4%ba%94%e4%b8%aa%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4\/","title":{"rendered":"Linux\u7684\u4e94\u4e2a\u67e5\u627e\u547d\u4ee4"},"content":{"rendered":"<p>\u5728Linux\u4e2d\uff0c\u6709\u5f88\u591a\u65b9\u6cd5\u53ef\u4ee5\u505a\u5230\u8fd9\u4e00\u70b9\u3002\u56fd\u5916\u7f51\u7ad9LinuxHaxor\u603b\u7ed3\u4e86\u4e94\u6761\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u770b\u770b\u81ea\u5df1\u77e5\u9053\u51e0\u6761\u3002\u5927\u591a\u6570\u7a0b\u5e8f\u5458\uff0c\u53ef\u80fd\u7ecf\u5e38\u4f7f\u7528\u5176\u4e2d\u76842\u52303\u6761\uff0c\u5bf9\u8fd95\u6761\u547d\u4ee4\u90fd\u5f88\u719f\u6089\u7684\u4eba\u5e94\u8be5\u662f\u4e0d\u591a\u7684\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/photo2.bababian.com\/usr491085\/upload1\/20091008\/sBoFRsKw+OzJFYyNE2EUUjQCJlBV+J99nAarJRhCxwMaFRhlSmG8BSw==.jpg\" alt=\"\" \/><\/p>\n<p><strong>1. find<\/strong><\/p>\n<p>find\u662f\u6700\u5e38\u89c1\u548c\u6700\u5f3a\u5927\u7684\u67e5\u627e\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u627e\u5230\u4efb\u4f55\u4f60\u60f3\u627e\u7684\u6587\u4ef6\u3002<\/p>\n<p>find\u7684\u4f7f\u7528\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><strong>$ find &lt;\u6307\u5b9a\u76ee\u5f55&gt; &lt;\u6307\u5b9a\u6761\u4ef6&gt; &lt;\u6307\u5b9a\u52a8\u4f5c&gt;<\/strong><\/p>\n<p>&#8211; &lt;\u6307\u5b9a\u76ee\u5f55&gt;\uff1a \u6240\u8981\u641c\u7d22\u7684\u76ee\u5f55\u53ca\u5176\u6240\u6709\u5b50\u76ee\u5f55\u3002\u9ed8\u8ba4\u4e3a\u5f53\u524d\u76ee\u5f55\u3002<\/p>\n<p>&#8211; &lt;\u6307\u5b9a\u6761\u4ef6&gt;\uff1a \u6240\u8981\u641c\u7d22\u7684\u6587\u4ef6\u7684\u7279\u5f81\u3002<\/p>\n<p>&#8211; &lt;\u6307\u5b9a\u52a8\u4f5c&gt;\uff1a \u5bf9\u641c\u7d22\u7ed3\u679c\u8fdb\u884c\u7279\u5b9a\u7684\u5904\u7406\u3002<\/p>\n<p>\u5982\u679c\u4ec0\u4e48\u53c2\u6570\u4e5f\u4e0d\u52a0\uff0cfind\u9ed8\u8ba4\u641c\u7d22\u5f53\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\uff0c\u5e76\u4e14\u4e0d\u8fc7\u6ee4\u4efb\u4f55\u7ed3\u679c\uff08\u4e5f\u5c31\u662f\u8fd4\u56de\u6240\u6709\u6587\u4ef6\uff09\uff0c\u5c06\u5b83\u4eec\u5168\u90fd\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<p>find\u7684\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<p><strong>$ find . -name &#8216;my*&#8217;<\/strong><\/p>\n<p>\u641c\u7d22\u5f53\u524d\u76ee\u5f55\uff08\u542b\u5b50\u76ee\u5f55\uff0c\u4ee5\u4e0b\u540c\uff09\u4e2d\uff0c\u6240\u6709\u6587\u4ef6\u540d\u4ee5my\u5f00\u5934\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>$ find . -name &#8216;my*&#8217; -ls<\/strong><\/p>\n<p>\u641c\u7d22\u5f53\u524d\u76ee\u5f55\u4e2d\uff0c\u6240\u6709\u6587\u4ef6\u540d\u4ee5my\u5f00\u5934\u7684\u6587\u4ef6\uff0c\u5e76\u663e\u793a\u5b83\u4eec\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p><strong>$ find . -type f -mmin -10<\/strong><\/p>\n<p>\u641c\u7d22\u5f53\u524d\u76ee\u5f55\u4e2d\uff0c\u6240\u6709\u8fc7\u53bb10\u5206\u949f\u4e2d\u66f4\u65b0\u8fc7\u7684\u666e\u901a\u6587\u4ef6\u3002\u5982\u679c\u4e0d\u52a0-type f\u53c2\u6570\uff0c\u5219\u641c\u7d22\u666e\u901a\u6587\u4ef6+\u7279\u6b8a\u6587\u4ef6+\u76ee\u5f55\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/photo2.bababian.com\/usr491085\/upload1\/20091008\/sPyDXwjuyGPa90ImF1FWWQd+VFEI7soi3o4IGCou34db1QpQ0ttCFyg==.jpg\" alt=\"\" \/><\/p>\n<p><strong>2. locate<\/strong><\/p>\n<p>locate\u547d\u4ee4\u5176\u5b9e\u662f&#8221;find -name&#8221;\u7684\u53e6\u4e00\u79cd\u5199\u6cd5\uff0c\u4f46\u662f\u8981\u6bd4\u540e\u8005\u5feb\u5f97\u591a\uff0c\u539f\u56e0\u5728\u4e8e\u5b83\u4e0d\u641c\u7d22\u5177\u4f53\u76ee\u5f55\uff0c\u800c\u662f\u641c\u7d22\u4e00\u4e2a\u6570\u636e\u5e93\uff08\/var\/lib\/locatedb\uff09\uff0c\u8fd9\u4e2a\u6570\u636e\u5e93\u4e2d\u542b\u6709\u672c\u5730\u6240\u6709\u6587\u4ef6\u4fe1\u606f\u3002Linux\u7cfb\u7edf\u81ea\u52a8\u521b\u5efa\u8fd9\u4e2a\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u6bcf\u5929\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\uff0c\u6240\u4ee5\u4f7f\u7528locate\u547d\u4ee4\u67e5\u4e0d\u5230\u6700\u65b0\u53d8\u52a8\u8fc7\u7684\u6587\u4ef6\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528locate\u4e4b\u524d\uff0c\u5148\u4f7f\u7528<strong>updatedb<\/strong>\u547d\u4ee4\uff0c\u624b\u52a8\u66f4\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<p>locate\u547d\u4ee4\u7684\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<p><strong>$ locate \/etc\/sh<\/strong><\/p>\n<p>\u641c\u7d22etc\u76ee\u5f55\u4e0b\u6240\u6709\u4ee5sh\u5f00\u5934\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>$ locate ~\/m<\/strong><\/p>\n<p>\u641c\u7d22\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\uff0c\u6240\u6709\u4ee5m\u5f00\u5934\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>$ locate -i ~\/m<\/strong><\/p>\n<p>\u641c\u7d22\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\uff0c\u6240\u6709\u4ee5m\u5f00\u5934\u7684\u6587\u4ef6\uff0c\u5e76\u4e14\u5ffd\u7565\u5927\u5c0f\u5199\u3002<\/p>\n<p><strong>3. whereis<\/strong><\/p>\n<p>whereis\u547d\u4ee4\u53ea\u80fd\u7528\u4e8e\u7a0b\u5e8f\u540d\u7684\u641c\u7d22\uff0c\u800c\u4e14\u53ea\u641c\u7d22\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08\u53c2\u6570-b\uff09\u3001man\u8bf4\u660e\u6587\u4ef6\uff08\u53c2\u6570-m\uff09\u548c\u6e90\u4ee3\u7801\u6587\u4ef6\uff08\u53c2\u6570-s\uff09\u3002\u5982\u679c\u7701\u7565\u53c2\u6570\uff0c\u5219\u8fd4\u56de\u6240\u6709\u4fe1\u606f\u3002<\/p>\n<p>whereis\u547d\u4ee4\u7684\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<p><strong>$ whereis grep<\/strong><\/p>\n<p><strong>4. which<\/strong><\/p>\n<p>which\u547d\u4ee4\u7684\u4f5c\u7528\u662f\uff0c\u5728PATH\u53d8\u91cf\u6307\u5b9a\u7684\u8def\u5f84\u4e2d\uff0c\u641c\u7d22\u67d0\u4e2a\u7cfb\u7edf\u547d\u4ee4\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8fd4\u56de\u7b2c\u4e00\u4e2a\u641c\u7d22\u7ed3\u679c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f7f\u7528which\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u67d0\u4e2a\u7cfb\u7edf\u547d\u4ee4\u662f\u5426\u5b58\u5728\uff0c\u4ee5\u53ca\u6267\u884c\u7684\u5230\u5e95\u662f\u54ea\u4e00\u4e2a\u4f4d\u7f6e\u7684\u547d\u4ee4\u3002<\/p>\n<p>which\u547d\u4ee4\u7684\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<p><strong>$ which grep<\/strong><\/p>\n<p><strong>5. type<\/strong><\/p>\n<p>type\u547d\u4ee4\u5176\u5b9e\u4e0d\u80fd\u7b97\u67e5\u627e\u547d\u4ee4\uff0c\u5b83\u662f\u7528\u6765\u533a\u5206\u67d0\u4e2a\u547d\u4ee4\u5230\u5e95\u662f\u7531shell\u81ea\u5e26\u7684\uff0c\u8fd8\u662f\u7531shell\u5916\u90e8\u7684\u72ec\u7acb\u4e8c\u8fdb\u5236\u6587\u4ef6\u63d0\u4f9b\u7684\u3002\u5982\u679c\u4e00\u4e2a\u547d\u4ee4\u662f\u5916\u90e8\u547d\u4ee4\uff0c\u90a3\u4e48\u4f7f\u7528-p\u53c2\u6570\uff0c\u4f1a\u663e\u793a\u8be5\u547d\u4ee4\u7684\u8def\u5f84\uff0c\u76f8\u5f53\u4e8ewhich\u547d\u4ee4\u3002<\/p>\n<p>type\u547d\u4ee4\u7684\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<p><strong>$ type cd<\/strong><\/p>\n<p>\u7cfb\u7edf\u4f1a\u63d0\u793a\uff0ccd\u662fshell\u7684\u81ea\u5e26\u547d\u4ee4\uff08build-in\uff09\u3002<\/p>\n<p><strong>$ type grep<\/strong><\/p>\n<p>\u7cfb\u7edf\u4f1a\u63d0\u793a\uff0cgrep\u662f\u4e00\u4e2a\u5916\u90e8\u547d\u4ee4\uff0c\u5e76\u663e\u793a\u8be5\u547d\u4ee4\u7684\u8def\u5f84\u3002<\/p>\n<p><strong>$ type -p grep<\/strong><\/p>\n<p>\u52a0\u4e0a-p\u53c2\u6570\u540e\uff0c\u5c31\u76f8\u5f53\u4e8ewhich\u547d\u4ee4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Linux\u4e2d\uff0c\u6709\u5f88\u591a\u65b9\u6cd5\u53ef\u4ee5\u505a\u5230\u8fd9\u4e00\u70b9\u3002\u56fd\u5916\u7f51\u7ad9LinuxHaxor\u603b\u7ed3\u4e86\u4e94\u6761\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u770b\u770b\u81ea\u5df1\u77e5\u9053\u51e0\u6761\u3002 &#8230; <a title=\"Linux\u7684\u4e94\u4e2a\u67e5\u627e\u547d\u4ee4\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/jishu\/fuwuqi\/linux%e7%9a%84%e4%ba%94%e4%b8%aa%e6%9f%a5%e6%89%be%e5%91%bd%e4%bb%a4\/\" aria-label=\"\u9605\u8bfb Linux\u7684\u4e94\u4e2a\u67e5\u627e\u547d\u4ee4\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[49,9],"tags":[],"class_list":["post-3326","post","type-post","status-publish","format-standard","hentry","category-linux","category-fuwuqi"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3326"}],"version-history":[{"count":2,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3326\/revisions"}],"predecessor-version":[{"id":9877,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3326\/revisions\/9877"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}