{"id":51897,"date":"2024-12-03T11:28:20","date_gmt":"2024-12-03T03:28:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/51897\/"},"modified":"2024-12-03T11:28:20","modified_gmt":"2024-12-03T03:28:20","slug":"linux-locate%e5%91%bd%e4%bb%a4%e7%9a%84%e4%bd%9c%e7%94%a8%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/51897\/","title":{"rendered":"linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48<\/h1>\n<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300alinux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span><\/p>\n<\/p>\n<blockquote>\n<p>linux locate\u547d\u4ee4\u7528\u6765\u67e5\u627e\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u8bed\u6cd5\u201clocate [OPTION]&#8230; [PATTERN]&#8230;\u201d\u3002locate\u547d\u4ee4\u641c\u7d22\u7684\u4e0d\u662f\u5177\u4f53\u76ee\u5f55\uff0c\u800c\u662f\u4e00\u4e2a\u6570\u636e\u5e93\u201c\/var\/lib\/mlocate\/mlocate.db\u201d\uff0c\u5176\u6570\u636e\u5e93\u4e2d\u542b\u6709\u672c\u5730\u6240\u6709\u6587\u4ef6\u4fe1\u606f\uff1b\u7cfb\u7edf\u81ea\u52a8\u521b\u5efa\u8fd9\u4e2a\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u6bcf\u5929\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\u3002<\/p>\n<\/blockquote>\n<p>Linux \u4e2d\u7684 locate \u547d\u4ee4\u7528\u6765\u67e5\u627e\u6587\u4ef6\u6216\u76ee\u5f55\u3002 locate \u547d\u4ee4\u8981\u6bd4 <code>find -name<\/code> \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 <code>\/var\/lib\/mlocate\/mlocate.db<\/code>\u3002<\/p>\n<p><strong>Linux locate\u547d\u4ee4<\/strong><\/p>\n<p>Linux locate \u547d\u4ee4\u4f7f\u7528\u7684\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\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u7528 whereis \u548c locate \u67e5\u627e\u6587\u4ef6\u65f6\uff0c\u6709\u65f6\u4f1a\u627e\u5230\u5df2\u7ecf\u88ab\u5220\u9664\u7684\u6570\u636e\uff0c\u6216\u8005\u521a\u521a\u5efa\u7acb\u6587\u4ef6\uff0c\u5374\u65e0\u6cd5\u67e5\u627e\u5230\uff0c\u539f\u56e0\u5c31\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u6587\u4ef6\u6ca1\u6709\u88ab\u66f4\u65b0\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528 locate \u4e4b\u524d\uff0c\u5148\u4f7f\u7528 updatedb \u547d\u4ee4\uff0c\u624b\u52a8\u66f4\u65b0\u6570\u636e\u5e93\u3002\u6574\u4e2a locate \u5de5\u4f5c\u5176\u5b9e\u662f\u7531\u56db\u90e8\u5206\u7ec4\u6210\u7684:<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7ec4\u6210<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\/usr\/bin\/updatedb<\/td>\n<td>\u4e3b\u8981\u7528\u6765\u66f4\u65b0\u6570\u636e\u5e93\uff0c\u901a\u8fc7 crontab \u81ea\u52a8\u5b8c\u6210\u7684\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/usr\/bin\/locate<\/td>\n<td>\u67e5\u8be2\u6587\u4ef6\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\/etc\/updatedb.conf<\/td>\n<td>updatedb \u7684\u914d\u7f6e\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\/var\/lib\/mlocate\/mlocate.db<\/td>\n<td>\u5b58\u653e\u6587\u4ef6\u4fe1\u606f\u7684\u6587\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u8bed\u6cd5<\/strong><\/p>\n<pre>locate&nbsp;[OPTION]...&nbsp;[PATTERN]...<\/pre>\n<p>\u53c2\u6570<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b9e\u4f8b<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>locate &nbsp;file<\/td>\n<td>\u67e5\u627e\u6587\u4ef6 file<\/td>\n<\/tr>\n<tr>\n<td>locate &nbsp;-i file<\/td>\n<td>\u5ffd\u7565\u5927\u5c0f\u5199\u67e5\u627e\u6587\u4ef6 file<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>locate\u67e5\u627e\u6587\u4ef6<\/strong><\/p>\n<p>\u8bed\u6cd5<\/p>\n<pre>&nbsp;locate&nbsp;file<\/pre>\n<p><strong>\u6848\u4f8b1<\/strong><\/p>\n<p>\u6211\u4eec\u4f7f\u7528 locate \u547d\u4ee4\uff0c\u67e5\u627e etc \u76ee\u5f55\u4e0b my \u5f00\u59cb\u7684\u6587\u4ef6\uff0c\u5177\u4f53\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre>locate&nbsp;\/etc\/my<\/pre>\n<p>\u8fd0\u884c\u540e\uff0c\u7ec8\u7aef\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240329\/17117204706606c81669685.jpg\" class=\"aligncenter\" title=\"linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u63d2\u56fe\" alt=\"linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u63d2\u56fe\" \/><\/p>\n<p>\u6211\u4eec\u770b\u5230\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 locate \u547d\u4ee4\uff0c\u67e5\u627e\u4e86 etc \u76ee\u5f55\u4e0b\u6240\u6709\u4ee5 my \u5f00\u59cb\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>\u6848\u4f8b2<\/strong><\/p>\n<p>\u6211\u4eec\u4f7f\u7528 locate \u547d\u4ee4\uff0c\u67e5\u627e Linux \u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u5177\u4f53\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre>locate&nbsp;install.log<\/pre>\n<p>\u8fd0\u884c\u540e\uff0c\u7ec8\u7aef\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240329\/17117204706606c8166c9b9.png\" class=\"aligncenter\" title=\"linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u63d2\u56fe1\" alt=\"linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u63d2\u56fe1\" \/><\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300alinux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48 \u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60\u6587\u7ae0\uff0c\u90a3\u4e48\u672c\u6587\u300alinux locate\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~ linux locate\u547d\u4ee4\u7528\u6765\u67e5\u627e\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u8bed\u6cd5\u201clocate [OPTION]&#8230; [PATTERN]&#8230;\u201d\u3002locate\u547d\u4ee4\u641c\u7d22\u7684\u4e0d\u662f\u5177\u4f53\u76ee\u5f55\uff0c\u800c\u662f\u4e00\u4e2a\u6570\u636e\u5e93\u201c\/var\/lib\/mlocate\/mlocate.db\u201d\uff0c\u5176\u6570\u636e\u5e93\u4e2d\u542b\u6709\u672c\u5730\u6240\u6709\u6587\u4ef6\u4fe1\u606f\uff1b\u7cfb\u7edf\u81ea\u52a8\u521b\u5efa\u8fd9\u4e2a\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u6bcf\u5929\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\u3002 Linux \u4e2d\u7684 locate \u547d\u4ee4\u7528\u6765\u67e5\u627e\u6587\u4ef6\u6216\u76ee\u5f55\u3002 locate \u547d\u4ee4\u8981\u6bd4 find -name \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 \/var\/lib\/mlocate\/mlocate.db\u3002 Linux locate\u547d\u4ee4 Linux locate \u547d\u4ee4\u4f7f\u7528\u7684\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\u3002 \u56e0\u6b64\uff0c\u6211\u4eec\u5728\u7528 whereis \u548c locate \u67e5\u627e\u6587\u4ef6\u65f6\uff0c\u6709\u65f6\u4f1a\u627e\u5230\u5df2\u7ecf\u88ab\u5220\u9664\u7684\u6570\u636e\uff0c\u6216\u8005\u521a\u521a\u5efa\u7acb\u6587\u4ef6\uff0c\u5374\u65e0\u6cd5\u67e5\u627e\u5230\uff0c\u539f\u56e0\u5c31\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u6587\u4ef6\u6ca1\u6709\u88ab\u66f4\u65b0\u3002 \u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528 locate \u4e4b\u524d\uff0c\u5148\u4f7f\u7528 updatedb \u547d\u4ee4\uff0c\u624b\u52a8\u66f4\u65b0\u6570\u636e\u5e93\u3002\u6574\u4e2a locate \u5de5\u4f5c\u5176\u5b9e\u662f\u7531\u56db\u90e8\u5206\u7ec4\u6210\u7684: \u7ec4\u6210 \u63cf\u8ff0 \/usr\/bin\/updatedb \u4e3b\u8981\u7528\u6765\u66f4\u65b0\u6570\u636e\u5e93\uff0c\u901a\u8fc7 crontab \u81ea\u52a8\u5b8c\u6210\u7684\u3002 \/usr\/bin\/locate \u67e5\u8be2\u6587\u4ef6\u4f4d\u7f6e \/etc\/updatedb.conf updatedb \u7684\u914d\u7f6e\u6587\u4ef6 \/var\/lib\/mlocate\/mlocate.db \u5b58\u653e\u6587\u4ef6\u4fe1\u606f\u7684\u6587\u4ef6 \u8bed\u6cd5 locate&nbsp;[OPTION]&#8230;&nbsp;[PATTERN]&#8230; \u53c2\u6570 \u5b9e\u4f8b \u63cf\u8ff0 locate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-51897","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=51897"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51897\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=51897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=51897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=51897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}