{"id":194462,"date":"2020-06-29T09:05:45","date_gmt":"2020-06-29T01:05:45","guid":{"rendered":"https:\/\/gulass.cn\/?p=194462"},"modified":"2020-06-24T10:09:18","modified_gmt":"2020-06-24T02:09:18","slug":"find-locate","status":"publish","type":"post","link":"https:\/\/gulass.cn\/find-locate.html","title":{"rendered":"\u9664\u4e86find\u547d\u4ee4\uff0c\u8fd8\u6709\u8fd9\u4e48\u591a\u6587\u4ef6\u67e5\u627e\u547d\u4ee4\uff01"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6587\u4ef6\u641c\u7d22\u547d\u4ee4\u8fdc\u4e0d\u6b62\u4e00\u4e2a find \u547d\u4ee4\uff0c\u8fd8\u6709\u5f88\u591a\u3002\u672c\u6587\u5c31\u5bf9 Linux \u4e0b\u6587\u4ef6\u641c\u7d22\u547d\u4ee4\u8fdb\u884c\u4e00\u4e2a\u79d1\u666e\uff0c\u8ba9\u4f60\u80fd\u591f\u5728\u77ed\u65f6\u95f4\u5185\u627e\u5230\u81ea\u5df1\u9700\u8981\u7684\u6587\u4ef6\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728\u7cfb\u7edf\u91cc\u67e5\u627e\u6587\u4ef6\uff0c\u662f\u6240\u6709\u5de5\u7a0b\u5e08\u90fd\u5fc5\u5907\u7684\u6280\u80fd(\u4e0d\u7ba1\u4f60\u7528\u7684\u662f Windows \u3001Linux\u3001\u8fd8\u662f MacOS \u7cfb\u7edf)\u3002\u5bf9\u4e8e Linux \u64cd\u4f5c\u7cfb\u7edf\uff0c\u5355\u5355\u4e00\u4e2a find \u547d\u4ee4\u5c31\u53ef\u4ee5\u5b8c\u6210\u975e\u5e38\u591a\u7684\u641c\u7d22\u5de5\u4f5c\u3002<\/p>\n

\u4f46\u662f\uff0c\u6587\u4ef6\u641c\u7d22\u547d\u4ee4\u8fdc\u4e0d\u6b62\u4e00\u4e2a find \u547d\u4ee4\uff0c\u8fd8\u6709\u5f88\u591a\u3002\u672c\u6587\u5c31\u5bf9 Linux \u4e0b\u6587\u4ef6\u641c\u7d22\u547d\u4ee4\u8fdb\u884c\u4e00\u4e2a\u79d1\u666e\uff0c\u8ba9\u4f60\u80fd\u591f\u5728\u77ed\u65f6\u95f4\u5185\u627e\u5230\u81ea\u5df1\u9700\u8981\u7684\u6587\u4ef6\u3002<\/p>\n

\"\"<\/p>\n

1. find<\/strong><\/div>\n

find \u547d\u4ee4\u5e94\u8be5\u662f\u6700\u7ecf\u5178\u7684\u547d\u4ee4\u4e86\uff0c\u8c08\u5230\u641c\u7d22\u5de5\u5177\u7b2c\u4e00\u4e2a\u60f3\u5230\u7684\u80af\u5b9a\u662f find \u547d\u4ee4\u3002\u4f46\u662f\uff0cfind \u547d\u4ee4\u975e\u5e38\u5f3a\u5927\uff0c\u60f3\u8981\u628a\u5b83\u7684\u529f\u80fd\u90fd\u4ecb\u7ecd\u4e00\u904d\uff0c\u6050\u6015\u8981\u5199\u597d\u51e0\u7bc7\u6587\u7ae0\u3002<\/p>\n

\u6240\u4ee5\uff0c\u8fd9\u91cc\u5c31\u5077\u4e2a\u61d2\uff0c\u4ecb\u7ecd\u6700\u57fa\u672c\u7684\uff0c\u6839\u636e\u6587\u4ef6\u540d\u67e5\u627e\u6587\u4ef6\u7684\u65b9\u6cd5\u3002\u5047\u5982\u6211\u4eec\u60f3\u641c\u7d22\u5f53\u524d\u76ee\u5f55(\u53ca\u5176\u5b50\u76ee\u5f55)\u4e0b\u6240\u6709 .sh \u6587\u4ef6\uff0c\u53ef\u4ee5\u8fd9\u6837\u641c\u7d22\uff1a<\/p>\n

\"\"<\/p>\n

2. locate<\/strong><\/div>\n

locate \u662f\u53e6\u5916\u4e00\u4e2a\u6839\u636e\u6587\u4ef6\u540d\u6765\u641c\u7d22\u6587\u4ef6\u7684\u547d\u4ee4\u3002\u533a\u522b\u4e8e find \u547d\u4ee4\uff0clocate \u547d\u4ee4\u65e0\u9700\u6307\u5b9a\u8def\u5f84\uff0c\u76f4\u63a5\u641c\u7d22\u5373\u53ef\u3002<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u4e0d\u662f\u76f4\u63a5\u53bb\u7cfb\u7edf\u7684\u5404\u4e2a\u89d2\u843d\u641c\u7d22\u6587\u4ef6\uff0c\u800c\u662f\u5728\u4e00\u4e2a\u53eb mlocate.db \u7684\u6570\u636e\u5e93\u4e0b\u641c\u7d22\u3002\u8fd9\u4e2a\u6570\u636e\u5e93\u4f4d\u4e8e \/var\/lib\/mlocate\/mlocate.db \uff0c\u5b83\u5305\u542b\u4e86\u7cfb\u7edf\u91cc\u6240\u6709\u6587\u4ef6\u7684\u7d22\u5f15\uff0c\u5e76\u4e14\u4f1a\u5728\u6bcf\u5929\u65e9\u4e0a\u7684\u65f6\u5019\u7531 cron \u5de5\u5177\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\u3002<\/p>\n

\u6b63\u56e0\u4e3a\u5982\u6b64\uff0clocate \u7684\u641c\u7d22\u901f\u5ea6\u8fdc\u5feb\u4e8e find \u547d\u4ee4\uff0c\u56e0\u4e3a\u5b83\u76f4\u63a5\u5728\u6570\u636e\u5e93\u91cc\u68c0\u7d22\uff0c\u901f\u5ea6\u81ea\u7136\u66f4\u5feb\u3002<\/p>\n

locate \u547d\u4ee4\u5728\u627e\u5230\u6587\u4ef6\u4e4b\u540e\uff0c\u5c06\u76f4\u63a5\u663e\u793a\u8be5\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u6bd4\u5982\uff1a<\/p>\n

\"\"<\/p>\n

\u4f46\u662f locate \u547d\u4ee4\u6709\u4e2a\u5f0a\u7aef\uff0c\u5b83\u65e0\u6cd5\u641c\u7d22\u5f53\u5929\u6240\u521b\u5efa\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u5b83\u7684\u6570\u636e\u5e93\u4e00\u5929\u53ea\u5728\u65e9\u4e0a\u66f4\u65b0\u4e00\u6b21\u3002\u6bd4\u5982\u6211\u73b0\u5728\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0clocate \u6ca1\u529e\u6cd5\u641c\u7d22\u5230\uff1a
\n\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 updatedb \u547d\u4ee4\u624b\u52a8\u53bb\u66f4\u65b0\u5b83\u7684\u6570\u636e\u5e93\uff1a sudo updadb
\n\"\"<\/p>\n

3. which
\n<\/strong><\/div>\n

which \u547d\u4ee4\u4e3b\u8981\u7528\u6765\u67e5\u627e\u53ef\u6267\u884c\u6587\u4ef6\u7684\u4f4d\u7f6e\uff0c\u5b83\u641c\u7d22\u7684\u4f4d\u7f6e\u6307\u5b9a\u5728 $PATH \u53ca $MANPATH \u73af\u5883\u53d8\u91cf\u4e0b\u7684\u503c\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cwhich \u547d\u4ee4\u5c06\u663e\u793a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7b2c\u4e00\u4e2a\u5b58\u50a8\u4f4d\u7f6e\uff1a<\/p>\n

\u5982\u679c\u67d0\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u5b58\u50a8\u5728\u591a\u4e2a\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 -a \u9009\u9879\u5217\u51fa\u6240\u6709\u7684\u4f4d\u7f6e\u3002<\/p>\n

\u5982\u679c\u4f60\u60f3\u4e00\u6b21\u6027\u67e5\u627e\u591a\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u76f4\u63a5\u8ddf\u5728 which \u547d\u4ee4\u540e\u9762\u5373\u53ef\u3002
\n\"\"<\/p>\n

4. whereis<\/strong><\/div>\n

whereis \u547d\u4ee4\u4f1a\u5728\u7cfb\u7edf\u9ed8\u8ba4\u5b89\u88c5\u76ee\u5f55(\u4e00\u822c\u662f\u6709root\u6743\u9650\u65f6\u9ed8\u8ba4\u5b89\u88c5\u7684\u8f6f\u4ef6)\u67e5\u627e\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001\u6e90\u7801\u3001\u6587\u6863\u4e2d\u5305\u542b\u7ed9\u5b9a\u67e5\u8be2\u5173\u952e\u8bcd\u7684\u6587\u4ef6\u3002(\u9ed8\u8ba4\u76ee\u5f55\u6709 \/bin, \/sbin, \/usr\/bin, \/usr\/lib,\/usr\/local\/man\u7b49\u7c7b\u4f3c\u8def\u5f84)\u3002<\/p>\n

\u4e00\u822c\u5305\u542b\u4ee5\u4e0b\u4e09\u90e8\u5206\u5185\u5bb9\uff1a<\/p>\n

\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u8def\u5f84<\/p>\n

\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u6e90\u7801\u8def\u5f84<\/p>\n

\u5bf9\u5e94 man \u6587\u4ef6\u7684\u8def\u5f84<\/p>\n

\u6bd4\u5982\u6211\u4eec\u73b0\u5728\u641c\u7d22 ls \u547d\u4ee4\uff1a<\/p>\n

\"\"<\/p>\n

\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 -b \u9009\u9879\u6765\u53ea\u641c\u7d22\u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728\u4f4d\u7f6e\uff0c\u4f7f\u7528 -B \u9009\u9879\u6307\u5b9a\u641c\u7d22\u4f4d\u7f6e\uff0c\u4f7f\u7528 -f \u9009\u9879\u5217\u51fa\u6587\u4ef6\u7684\u4fe1\u606f\u3002<\/p>\n

\u540c\u6837\u5730\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 -s \u9650\u5b9a\u53ea\u641c\u7d22\u6e90\u7801\u8def\u5f84\uff0c\u4f7f\u7528 -m \u641c\u7d22 man page \u8def\u5f84\uff0c\u4f7f\u7528 -s \u6307\u5b9a\u641c\u7d22\u6e90\u4ee3\u7801\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4f7f\u7528 -M \u6307\u5b9a\u641c\u7d22\u5e2e\u52a9\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u7cfb\u7edf\u91cc\u67e5\u627e\u6587\u4ef6\uff0c\u662f\u6240\u6709\u5de5\u7a0b\u5e08\u90fd\u5fc5\u5907\u7684\u6280\u80fd(\u4e0d\u7ba1\u4f60\u7528\u7684\u662f Windows \u3001Linux\u3001\u8fd8\u662f MacOS \u7cfb\u7edf […]<\/p>\n","protected":false},"author":370,"featured_media":49097,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-194462","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/194462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=194462"}],"version-history":[{"count":4,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/194462\/revisions"}],"predecessor-version":[{"id":194539,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/194462\/revisions\/194539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/49097"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=194462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=194462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=194462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}