{"id":67,"date":"2023-11-20T23:14:51","date_gmt":"2023-11-20T15:14:51","guid":{"rendered":"http:\/\/8.141.4.74\/?p=67"},"modified":"2024-03-29T14:32:21","modified_gmt":"2024-03-29T06:32:21","slug":"rocky-linux-%e5%ae%89%e8%a3%85locate","status":"publish","type":"post","link":"http:\/\/8.141.4.74\/?p=67","title":{"rendered":"Rocky Linux \u5b89\u88c5locate"},"content":{"rendered":"<h1>Rocky Linux \u5b89\u88c5locate<\/h1>\n<blockquote>\n<p>locate \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u6765\u5728 Linux \u7cfb\u7edf\u4e2d\u67e5\u627e\u6587\u4ef6\u3002\u5b83\u4f7f\u7528\u4e00\u4e2a\u6570\u636e\u5e93\u6765\u5b58\u50a8\u6587\u4ef6\u8def\u5f84\u4fe1\u606f\uff0c\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528 locate \u547d\u4ee4\u6765\u5feb\u901f\u67e5\u627e\u6587\u4ef6\u800c\u4e0d\u9700\u8981\u5728\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u4e2d\u8fdb\u884c\u641c\u7d22\u3002<\/p>\n<\/blockquote>\n<h2>1.\u6709\u5173 locate \u547d\u4ee4\u7684\u9519\u8bef\u63d0\u793a<\/h2>\n<p>\u4f46\u662f\u5f53\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u7684\u65f6\u5019\u6709\u4e00\u4e9b\u9519\u8bef\u63d0\u793a\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash\">[root@centos8 ~]#local\nlocal      locale     localectl  localedef\n#\u901a\u8fc7TAB\u952e\u8865\u5168\uff0c\u53ef\u4ee5\u53d1\u73b0\u662f\u6ca1\u6709locate\u547d\u4ee4\u7684\n[root@centos8 ~]#locate\n-bash: locate: command not found<\/code><\/pre>\n<p>\u901a\u8fc7 <strong>updatedb<\/strong> \u6765\u66f4\u65b0\u6570\u636e\u5e93\u7684\u65f6\u5019\u4e5f\u62a5\u9519\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">[root@centos8 ~]#updatedb\n-bash: updatedb: command not found<\/code><\/pre>\n<h2>2.\u5b89\u88c5 mlocate \u5de5\u5177<\/h2>\n<p><strong>mlocate<\/strong> \u662f\u4e00\u4e2a\u7528\u6765\u7ef4\u62a4\u8fd9\u4e2a\u6570\u636e\u5e93\u7684\u5de5\u5177\u3002\u5b83\u4f1a\u626b\u63cf\u6587\u4ef6\u7cfb\u7edf\u5e76\u5efa\u7acb\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u91cc\u9762\u5305\u542b\u4e86\u6587\u4ef6\u7684\u8def\u5f84\u4fe1\u606f\u3002\u7136\u540e\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528 locate \u547d\u4ee4\u6765\u67e5\u627e\u6587\u4ef6\u4e86\u3002<\/p>\n<pre><code class=\"language-shell\">[root@centos8 ~]#yum -y install mlocate\nLast metadata expiration check: 0:17:25 ago on Tue 17 Jan 2023 11:17:52 AM CST.\nDependencies resolved.\n==========================================================================================================================================\n Package                         Architecture                   Version                              Repository                      Size\n==========================================================================================================================================\nInstalling:\n mlocate                         x86_64                         0.26-20.el8                          baseos                         121 k\n\nTransaction Summary\n==========================================================================================================================================\nInstall  1 Package\n\nTotal download size: 121 k\nInstalled size: 393 k\nDownloading Packages:\nmlocate-0.26-20.el8.x86_64.rpm                                                                            130 kB\/s | 121 kB     00:00\n------------------------------------------------------------------------------------------------------------------------------------------\nTotal                                                                                                     130 kB\/s | 121 kB     00:00\nRunning transaction check\nTransaction check succeeded.\nRunning transaction test\nTransaction test succeeded.\nRunning transaction\n  Preparing        :                                                                                                                  1\/1\n  Running scriptlet: mlocate-0.26-20.el8.x86_64                                                                                       1\/1\n  Installing       : mlocate-0.26-20.el8.x86_64                                                                                       1\/1\n  Running scriptlet: mlocate-0.26-20.el8.x86_64                                                                                       1\/1\n  Verifying        : mlocate-0.26-20.el8.x86_64                                                                                       1\/1\n\nInstalled:\n  mlocate-0.26-20.el8.x86_64\n\nComplete!\n<\/code><\/pre>\n<p>\u5f53\u6211\u4eec\u5b89\u88c5\u8fd9\u4e2a\u5de5\u5177\u4ee5\u540e\uff0c\u4f7f\u7528 <strong>locate<\/strong> \u547d\u4ee4\u6765\u641c\u7d22\u7684\u8bdd\uff0c\u8fd8\u662f\u4f1a\u63d0\u793a\u9519\u8bef\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">[root@centos8 ~]#loca\nlocal      locale     localectl  localedef  locate\n#\u5f53\u6211\u4eec\u4f7f\u7528tab\u952e\u8865\u5168\u7684\u65f6\u5019\u53d1\u73b0\u5df2\u7ecf\u6709\u4e86 locate \u8fd9\u4e2a\u547d\u4ee4\uff0c\u4f46\u662f\u6211\u4eec\u4f7f\u7528\u7684\u65f6\u5019\u8fd8\u662f\u4f1a\u62a5\u9519\uff0c\u5982\u4e0b\uff1a\n[root@centos8 ~]#locate passwd #\u8fd9\u6761\u547d\u4ee4\u4f1a\u5728 mlocate \u6570\u636e\u5e93\u4e2d\u67e5\u627e\u6240\u6709\u6587\u4ef6\u540d\u5305\u542b &quot;passwd&quot; \u7684\u6587\u4ef6\u3002\nlocate: can not stat () `\/var\/lib\/mlocate\/mlocate.db&#039;: No such file or directory\n#\u8fd9\u8bf4\u660e mlocate \u6570\u636e\u5e93\u6587\u4ef6 \/var\/lib\/mlocate\/mlocate.db \u4e0d\u5b58\u5728\u3002<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230 <strong>locate<\/strong> \u8fd9\u4e2a\u547d\u4ee4\u5df2\u7ecf\u6709\u4e86\uff0c\u4f46\u662f\u4f7f\u7528\u4e3a\u4ec0\u4e48\u8fd8\u4f1a\u62a5\u9519\u5462\uff1f<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u4f7f\u7528 <strong>updatedb<\/strong> \u6765\u66f4\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<h2>3.\u4f7f\u7528updatedb\u66f4\u65b0\u6570\u636e\u5e93<\/h2>\n<pre><code class=\"language-shell\">[root@centos8 ~]#update\nupdate-alternatives     update-crypto-policies  update-mime-database\nupdate-ca-trust         updatedb                update-pciids\n#\u901a\u8fc7tab\u952e\u53d1\u73b0\u5df2\u7ecf\u6709updatedb\u8fd9\u4e2a\u547d\u4ee4\n[root@centos8 ~]#updatedb\n[root@centos8 ~]#<\/code><\/pre>\n<p>\u518d\u6b21\u641c\u7d22 <strong>passwd<\/strong><\/p>\n<pre><code class=\"language-shell\">[root@centos8 ~]#locate passwd\n\/data\/user_passwd.log\n\/etc\/passwd\n\/etc\/passwd-\n\/etc\/pam.d\/passwd\n\/etc\/security\/opasswd\n\/usr\/bin\/gpasswd\n\/usr\/bin\/grub2-mkpasswd-pbkdf2\n\/usr\/bin\/htpasswd\n\/usr\/bin\/passwd\n\/usr\/lib\/firewalld\/services\/kpasswd.xml\n\/usr\/lib\/security\/pam_unix_passwd.so\n\/usr\/lib64\/security\/pam_unix_passwd.so\n\/usr\/sbin\/chgpasswd\n\/usr\/sbin\/chpasswd\n\/usr\/sbin\/lpasswd\n\/usr\/sbin\/saslpasswd2\n\/usr\/share\/awk\/passwd.awk\n\/usr\/share\/bash-completion\/completions\/chpasswd\n\/usr\/share\/bash-completion\/completions\/gpasswd\n\/usr\/share\/bash-completion\/completions\/htpasswd\n\/usr\/share\/bash-completion\/completions\/ldappasswd\n\/usr\/share\/bash-completion\/completions\/passwd\n\/usr\/share\/bash-completion\/completions\/smbpasswd\n\/usr\/share\/doc\/passwd\n\/usr\/share\/doc\/passwd\/AUTHORS\n\/usr\/share\/doc\/passwd\/ChangeLog\n\/usr\/share\/doc\/passwd\/NEWS\n\/usr\/share\/licenses\/passwd\n\/usr\/share\/licenses\/passwd\/COPYING\n\/usr\/share\/locale\/ar\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/as\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ast\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/bg\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/bn\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/bn_IN\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/bs\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ca\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/cs\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/cy\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/da\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/de\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/el\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/en_GB\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/es\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/et\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/eu\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/fa\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/fi\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/fr\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/gl\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/gu\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/he\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/hi\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/hr\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/hu\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/hy\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/id\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/is\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/it\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ja\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ka\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/kn\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ko\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ku\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/lo\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/mk\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ml\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/mr\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ms\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/my\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/nb\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/nds\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/nl\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/nn\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/or\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/pa\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/pl\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/pt\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/pt_BR\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ro\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ru\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/si\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sk\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sl\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sq\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sr\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sr@latin\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/sv\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ta\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/te\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/tr\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/uk\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/ur\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/vi\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/wa\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/zh_CN\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/locale\/zh_TW\/LC_MESSAGES\/passwd.mo\n\/usr\/share\/man\/cs\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/de\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/de\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/de\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/fr\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/fr\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/fr\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/hu\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/it\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/it\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/it\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/ja\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/ja\/man1\/passwd.1.gz\n\/usr\/share\/man\/ja\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/man1\/grub2-mkpasswd-pbkdf2.1.gz\n\/usr\/share\/man\/man1\/htpasswd.1.gz\n\/usr\/share\/man\/man1\/lpasswd.1.gz\n\/usr\/share\/man\/man1\/openssl-passwd.1ssl.gz\n\/usr\/share\/man\/man1\/passwd.1.gz\n\/usr\/share\/man\/man1\/sslpasswd.1ssl.gz\n\/usr\/share\/man\/man3\/passwd2des.3.gz\n\/usr\/share\/man\/man5\/passwd.5.gz\n\/usr\/share\/man\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/pt_BR\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/ru\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/ru\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/ru\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/zh_CN\/man1\/gpasswd.1.gz\n\/usr\/share\/man\/zh_CN\/man8\/chgpasswd.8.gz\n\/usr\/share\/man\/zh_CN\/man8\/chpasswd.8.gz\n\/usr\/share\/man\/zh_TW\/man8\/chpasswd.8.gz\n\/usr\/share\/nmap\/scripts\/http-passwd.nse\n\/usr\/share\/vim\/vim80\/ftplugin\/passwd.vim\n\/usr\/share\/vim\/vim80\/syntax\/passwd.vim\n\/var\/lib\/sss\/mc\/passwd\n[root@centos8 ~]#<\/code><\/pre>\n<p>\u4ee5\u540e\u5c31\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528locate<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rocky Linux \u5b89\u88c5locate locate \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u6765\u5728 Linux \u7cfb\u7edf\u4e2d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[7,8],"views":267,"_links":{"self":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/67"}],"collection":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67"}],"version-history":[{"count":4,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":443,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/67\/revisions\/443"}],"wp:attachment":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}