{"id":106223,"date":"2026-09-16T22:40:29","date_gmt":"2026-09-16T14:40:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106223.html"},"modified":"2026-09-16T22:40:29","modified_gmt":"2026-09-16T14:40:29","slug":"linux%e6%9f%a5%e6%89%be%e6%96%87%e4%bb%b6%e5%91%bd%e4%bb%a4%ef%bc%9afind%e3%80%81locate%e3%80%81which%e3%80%81whereis%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106223.html","title":{"rendered":"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218"},"content":{"rendered":"<h3>\u5f00\u7bc7&#xff1a;<\/h3>\n<p>\u201c\u90a3\u4e2a nginx.conf \u5230\u5e95\u5728\u54ea&#xff1f;\u201d\u2014\u2014\u8fd9\u662f\u6bcf\u4e2a Linux \u65b0\u624b\u548c\u8001\u624b\u90fd\u4f1a\u9047\u5230\u7684\u7075\u9b42\u62f7\u95ee\u3002<\/p>\n<p>\u6709\u4e00\u6b21\u6211\u63a5\u624b\u4e00\u53f0&#034;\u7956\u4f20&#034;\u670d\u52a1\u5668&#xff0c;\u524d\u540c\u4e8b\u628a Nginx \u88c5\u5728\u4e86\u7f16\u8bd1\u76ee\u5f55\u91cc&#xff0c;\u914d\u7f6e\u6587\u4ef6\u65e2\u4e0d\u5728 \/etc\/nginx \u4e5f\u4e0d\u5728 \/usr\/local\/nginx\/conf\u3002\u6211\u7528\u4e86\u4e09\u62db\u5b9a\u4f4d&#xff1a;<\/p>\n<p><span class=\"token function\">which<\/span> nginx            <span class=\"token comment\"># \u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\u5728\u54ea\u4e2a\u76ee\u5f55<\/span><br \/>\n<span class=\"token function\">find<\/span> \/ <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;nginx.conf&#034;<\/span> <span class=\"token operator\"><span class=\"token file-descriptor important\">2<\/span>&gt;<\/span>\/dev\/null   <span class=\"token comment\"># \u5168\u76d8\u627e\u914d\u7f6e\u6587\u4ef6<\/span><\/p>\n<p>\u4e09\u5206\u949f\u5185\u5c31\u9501\u5b9a\u4e86\u76ee\u6807\u3002\u67e5\u627e\u6587\u4ef6&#xff0c;\u662f Linux \u8fd0\u7ef4\u548c\u5f00\u53d1\u7684\u9ad8\u9891\u521a\u9700\u3002\u4eca\u5929\u6211\u4eec\u628a find\u3001locate\u3001which\u3001whereis \u56db\u4e2a\u67e5\u627e\u547d\u4ee4\u4e00\u6b21\u8bb2\u900f&#xff0c;\u5e76\u8bf4\u6e05\u5b83\u4eec\u5404\u81ea\u9002\u5408\u4ec0\u4e48\u573a\u666f\u3002<\/p>\n<h3>\u4e00\u3001\u56db\u4e2a\u547d\u4ee4\u7684\u5b9a\u4f4d&#xff1a;\u4e00\u5f20\u8868\u5148\u5efa\u7acb\u5168\u5c40\u89c2<\/h3>\n<table>\n<tr>\u547d\u4ee4\u67e5\u627e\u5bf9\u8c61\u67e5\u627e\u4f9d\u636e\u901f\u5ea6\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>find<\/td>\n<td>\u4efb\u610f\u6587\u4ef6\/\u76ee\u5f55<\/td>\n<td>\u5b9e\u65f6\u626b\u63cf\u76ee\u5f55\u6811&#xff0c;\u6309\u540d\u5b57\/\u7c7b\u578b\/\u5927\u5c0f\/\u65f6\u95f4\u7b49\u6761\u4ef6<\/td>\n<td>\u6162&#xff08;\u4f46\u529f\u80fd\u6700\u5f3a&#xff09;<\/td>\n<td>\u7cbe\u786e\u3001\u590d\u6742\u6761\u4ef6\u67e5\u627e<\/td>\n<\/tr>\n<tr>\n<td>locate<\/td>\n<td>\u6587\u4ef6\u540d<\/td>\n<td>\u67e5\u8be2\u9884\u5efa\u6570\u636e\u5e93&#xff08;updatedb&#xff09;<\/td>\n<td>\u6781\u5feb<\/td>\n<td>\u6a21\u7cca\u8bb0\u5f97\u540d\u5b57\u7684\u5feb\u901f\u67e5\u627e<\/td>\n<\/tr>\n<tr>\n<td>which<\/td>\n<td>\u53ef\u6267\u884c\u547d\u4ee4<\/td>\n<td>\u641c\u7d22 PATH \u73af\u5883\u53d8\u91cf<\/td>\n<td>\u6781\u5feb<\/td>\n<td>\u547d\u4ee4\u88c5\u5728\u54ea\u4e2a\u76ee\u5f55\u3001\u662f\u5426\u5df2\u5b89\u88c5<\/td>\n<\/tr>\n<tr>\n<td>whereis<\/td>\n<td>\u53ef\u6267\u884c\u547d\u4ee4\u53ca\u5176\u6587\u6863<\/td>\n<td>\u641c\u7d22\u6807\u51c6\u76ee\u5f55 &#043; PATH<\/td>\n<td>\u5feb<\/td>\n<td>\u540c\u65f6\u627e\u4e8c\u8fdb\u5236\u3001\u6e90\u7801\u3001man \u624b\u518c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd\u8bb0\u5fc6&#xff1a;which\/whereis \u627e\u547d\u4ee4&#xff0c;locate \u5feb\u901f\u627e\u6587\u4ef6&#xff0c;find \u7cbe\u786e\u627e\u4e00\u5207\u3002<\/p>\n<h3>\u4e8c\u3001find&#xff1a;\u529f\u80fd\u6700\u5f3a\u7684&#034;\u641c\u7d22\u673a\u5668&#034;<\/h3>\n<h4>\u8bed\u6cd5\u683c\u5f0f<\/h4>\n<p><span class=\"token function\">find<\/span> <span class=\"token punctuation\">[<\/span>\u8d77\u59cb\u8def\u5f84<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">[<\/span>\u5339\u914d\u6761\u4ef6<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">[<\/span>\u52a8\u4f5c<span class=\"token punctuation\">]<\/span><\/p>\n<p>\u8d77\u59cb\u8def\u5f84\u4e0d\u5199\u9ed8\u8ba4\u662f\u5f53\u524d\u76ee\u5f55 .\u3002find \u4f1a\u9012\u5f52\u904d\u5386\u76ee\u5f55\u6811&#xff0c;\u9010\u9879\u5339\u914d\u6761\u4ef6&#xff0c;\u6700\u540e\u6267\u884c\u52a8\u4f5c&#xff08;\u9ed8\u8ba4\u52a8\u4f5c\u662f\u6253\u5370\u8def\u5f84&#xff09;\u3002<\/p>\n<h4>\u5e38\u7528\u5339\u914d\u6761\u4ef6<\/h4>\n<table>\n<tr>\u6761\u4ef6\u8bf4\u660e\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>-name &#034;\u6a21\u5f0f&#034;<\/td>\n<td>\u6309\u6587\u4ef6\u540d&#xff08;\u652f\u6301\u901a\u914d\u7b26&#xff0c;\u9700\u52a0\u5f15\u53f7&#xff09;<\/td>\n<td>-name &#034;*.log&#034;<\/td>\n<\/tr>\n<tr>\n<td>-iname &#034;\u6a21\u5f0f&#034;<\/td>\n<td>\u5ffd\u7565\u5927\u5c0f\u5199\u7684\u6587\u4ef6\u540d<\/td>\n<td>-iname &#034;Readme*&#034;<\/td>\n<\/tr>\n<tr>\n<td>-type f\/d\/l<\/td>\n<td>\u6309\u7c7b\u578b&#xff1a;\u6587\u4ef6\/\u76ee\u5f55\/\u7b26\u53f7\u94fe\u63a5<\/td>\n<td>-type f<\/td>\n<\/tr>\n<tr>\n<td>-size &#043;100M<\/td>\n<td>\u6309\u5927\u5c0f&#xff08;&#043; \u5927\u4e8e\u3001- \u5c0f\u4e8e&#xff09;<\/td>\n<td>-size &#043;1G<\/td>\n<\/tr>\n<tr>\n<td>-mtime &#043;7<\/td>\n<td>\u6309\u4fee\u6539\u65f6\u95f4&#xff1a;7 \u5929\u524d&#xff08;&#043;7&#xff09;\/7 \u5929\u5185&#xff08;-7&#xff09;<\/td>\n<td>-mtime -1<\/td>\n<\/tr>\n<tr>\n<td>-user \u7528\u6237\u540d<\/td>\n<td>\u6309\u5c5e\u4e3b<\/td>\n<td>-user www-data<\/td>\n<\/tr>\n<tr>\n<td>-perm 644<\/td>\n<td>\u6309\u6743\u9650<\/td>\n<td>-perm -4000&#xff08;\u627e SUID&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>-maxdepth N<\/td>\n<td>\u9650\u5236\u9012\u5f52\u6df1\u5ea6<\/td>\n<td>-maxdepth 2<\/td>\n<\/tr>\n<tr>\n<td>-empty<\/td>\n<td>\u7a7a\u6587\u4ef6\/\u7a7a\u76ee\u5f55<\/td>\n<td>-empty<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u5e38\u7528\u52a8\u4f5c<\/h4>\n<table>\n<tr>\u52a8\u4f5c\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>-print<\/td>\n<td>\u6253\u5370\u8def\u5f84&#xff08;\u9ed8\u8ba4\u52a8\u4f5c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>-exec \u547d\u4ee4 {} \\\\;<\/td>\n<td>\u5bf9\u6bcf\u4e2a\u7ed3\u679c\u6267\u884c\u547d\u4ee4&#xff0c;{} \u662f\u7ed3\u679c\u5360\u4f4d\u7b26<\/td>\n<\/tr>\n<tr>\n<td>-delete<\/td>\n<td>\u76f4\u63a5\u5220\u9664\u5339\u914d\u7684\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>-ls<\/td>\n<td>\u4ee5 ls -l \u683c\u5f0f\u5217\u51fa\u8be6\u7ec6\u4fe1\u606f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u5b9e\u6218\u793a\u4f8b\u4e0e\u9884\u671f\u8f93\u51fa<\/h4>\n<p>\u793a\u4f8b 1&#xff1a;\u6309\u540d\u5b57\u548c\u7c7b\u578b\u67e5\u627e<\/p>\n<p><span class=\"token function\">find<\/span> \/etc <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;*.conf&#034;<\/span> <span class=\"token parameter variable\">-type<\/span> f <span class=\"token operator\">|<\/span> <span class=\"token function\">head<\/span> <span class=\"token parameter variable\">-5<\/span><\/p>\n<p>\u9884\u671f\u8f93\u51fa&#xff1a;<\/p>\n<p>\/etc\/rsyslog.conf<br \/>\n\/etc\/adduser.conf<br \/>\n\/etc\/deluser.conf<br \/>\n\/etc\/logrotate.conf<br \/>\n\/etc\/ucf.conf<\/p>\n<p>\u793a\u4f8b 2&#xff1a;\u627e\u51fa 7 \u5929\u524d\u4fee\u6539\u7684\u5927\u65e5\u5fd7\u6587\u4ef6<\/p>\n<p><span class=\"token function\">find<\/span> \/var\/log <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;*.log&#034;<\/span> <span class=\"token parameter variable\">-mtime<\/span> &#043;7 <span class=\"token parameter variable\">-size<\/span> &#043;100M <span class=\"token parameter variable\">-ls<\/span><\/p>\n<p>\u8fd9\u6761\u547d\u4ee4\u628a&#034;\u8d85\u8fc7 7 \u5929\u6ca1\u52a8\u8fc7\u3001\u4e14\u5927\u4e8e 100MB \u7684\u65e5\u5fd7&#034;\u5217\u51fa\u6765&#xff0c;\u914d\u5408\u7b2c 92 \u7bc7\u7684 logrotate \u601d\u8def&#xff0c;\u5c31\u662f\u6e05\u7406\u78c1\u76d8\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n<p>\u793a\u4f8b 3&#xff1a;\u5bf9\u7ed3\u679c\u6279\u91cf\u6267\u884c\u547d\u4ee4\u2014\u2014\u5220\u9664\u4e34\u65f6\u6587\u4ef6<\/p>\n<p><span class=\"token function\">find<\/span> \/tmp <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;*.tmp&#034;<\/span> <span class=\"token parameter variable\">-type<\/span> f <span class=\"token parameter variable\">-exec<\/span> <span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-f<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc {} \u9010\u4e2a\u66ff\u6362\u4e3a\u627e\u5230\u7684\u6587\u4ef6\u8def\u5f84&#xff0c;\\\\; \u8868\u793a -exec \u547d\u4ee4\u7ed3\u675f&#xff08;\u6ce8\u610f\u5206\u53f7\u524d\u6709\u53cd\u659c\u6760&#xff09;\u3002<\/p>\n<p>\u793a\u4f8b 4&#xff1a;\u7edf\u8ba1\u67d0\u76ee\u5f55\u4e0b\u666e\u901a\u6587\u4ef6\u6570\u91cf<\/p>\n<p><span class=\"token function\">find<\/span> \/var\/log <span class=\"token parameter variable\">-type<\/span> f <span class=\"token operator\">|<\/span> <span class=\"token function\">wc<\/span> <span class=\"token parameter variable\">-l<\/span><\/p>\n<p>\u9884\u671f\u8f93\u51fa&#xff08;\u793a\u4f8b\u503c&#xff09;&#xff1a;<\/p>\n<p>128<\/p>\n<h4>\u26a0\ufe0f \u5e38\u89c1\u9519\u8bef\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h4>\n<li>-name \u7684\u901a\u914d\u7b26\u5fc5\u987b\u52a0\u5f15\u53f7&#xff1a;\u5199\u6210 find \/ -name *.log \u65f6&#xff0c;Shell \u4f1a\u5728 find \u6267\u884c\u524d\u5148\u628a *.log \u5c55\u5f00&#xff0c;\u5f80\u5f80\u5339\u914d\u4e0d\u5230\u6216\u5339\u914d\u9519\u8bef\u3002\u6b63\u786e\u5199\u6cd5\u662f -name &#034;*.log&#034;\u3002<\/li>\n<li>\u6743\u9650\u62a5\u9519\u5237\u5c4f&#xff1a;find \/ -name x \u4f1a\u904d\u5386\u6574\u4e2a\u7cfb\u7edf&#xff0c;\u9047\u5230\u65e0\u6743\u8bbf\u95ee\u7684\u76ee\u5f55\u4f1a\u5237\u51fa\u4e00\u5806 Permission denied\u3002\u52a0 2&gt;\/dev\/null \u5c4f\u853d\u9519\u8bef\u8f93\u51fa\u3002<\/li>\n<li>-delete \u614e\u7528&#xff1a;\u5b83\u5220\u9664\u540e\u4e0d\u53ef\u6062\u590d&#xff0c;\u52a1\u5fc5\u5148 -print \u9884\u89c8\u518d\u5220\u3002<\/li>\n<li>-exec \u522b\u5fd8 {} \u548c \\\\;&#xff1a;\u683c\u5f0f\u5199\u9519\u4f1a\u62a5 find: missing argument to -exec\u3002<\/li>\n<h3>\u4e09\u3001locate&#xff1a;\u6570\u636e\u5e93\u52a0\u6301\u7684&#034;\u79d2\u67e5&#034;<\/h3>\n<p>locate \u7684\u67e5\u627e\u901f\u5ea6\u662f&#034;\u79d2\u56de&#034;&#xff0c;\u56e0\u4e3a\u5b83\u4e0d\u626b\u63cf\u78c1\u76d8&#xff0c;\u800c\u662f\u67e5\u8be2\u4e00\u4e2a\u9884\u5148\u5efa\u597d\u7684\u6587\u4ef6\u540d\u6570\u636e\u5e93\u3002<\/p>\n<h4>\u8bed\u6cd5\u683c\u5f0f<\/h4>\n<p><span class=\"token function\">locate<\/span> <span class=\"token punctuation\">[<\/span>\u9009\u9879<span class=\"token punctuation\">]<\/span> \u5173\u952e\u8bcd<\/p>\n<h4>\u5e38\u7528\u53c2\u6570<\/h4>\n<table>\n<tr>\u53c2\u6570\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>-i<\/td>\n<td>\u5ffd\u7565\u5927\u5c0f\u5199<\/td>\n<\/tr>\n<tr>\n<td>-c<\/td>\n<td>\u53ea\u8f93\u51fa\u5339\u914d\u6570\u91cf<\/td>\n<\/tr>\n<tr>\n<td>-r \u6b63\u5219<\/td>\n<td>\u7528\u6b63\u5219\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td>-n \u6570\u5b57<\/td>\n<td>\u53ea\u663e\u793a\u524d N \u6761<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u793a\u4f8b\u4e0e\u9884\u671f\u8f93\u51fa<\/h4>\n<p>\u793a\u4f8b&#xff1a;\u627e\u540d\u5b57\u91cc\u5e26 docker \u7684\u6587\u4ef6<\/p>\n<p><span class=\"token function\">locate<\/span> <span class=\"token function\">docker<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">head<\/span> <span class=\"token parameter variable\">-10<\/span><\/p>\n<p>\u9884\u671f\u8f93\u51fa&#xff08;\u8282\u9009&#xff09;&#xff1a;<\/p>\n<p>\/etc\/apparmor.d\/docker<br \/>\n\/etc\/bash_completion.d\/docker<br \/>\n\/usr\/bin\/docker<br \/>\n\/usr\/share\/man\/man1\/docker.1.gz<\/p>\n<h4>\u26a0\ufe0f \u6ce8\u610f\u4e8b\u9879<\/h4>\n<p>\u6570\u636e\u5e93\u4e0d\u4f1a\u5b9e\u65f6\u66f4\u65b0\u3002\u521a\u521b\u5efa\u7684\u6587\u4ef6 locate \u53ef\u80fd\u627e\u4e0d\u5230&#xff0c;\u9700\u8981\u5148\u66f4\u65b0\u6570\u636e\u5e93&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> updatedb    <span class=\"token comment\"># Ubuntu\/Debian<\/span><\/p>\n<p>CentOS\/Rocky \u4f7f\u7528 yum install mlocate \u5b89\u88c5\u540e\u540c\u6837\u6709 updatedb\u3002\u53e6\u5916\u6709\u4e9b\u53d1\u884c\u7248\u9ed8\u8ba4\u4e0d\u88c5 locate&#xff08;\u5982\u65b0\u7248 Ubuntu \u7528 plocate&#xff09;&#xff0c;\u88c5\u4e00\u4e0b\u5373\u53ef\u3002<\/p>\n<p>\u5e38\u89c1\u9519\u8bef&#xff1a;\u4ee5\u4e3a locate \u627e\u4e0d\u5230\u5c31\u8bf4\u660e\u6587\u4ef6\u4e0d\u5b58\u5728\u2014\u2014\u5b83\u53ef\u80fd\u53ea\u662f\u6570\u636e\u5e93\u8fc7\u671f\u4e86\u3002<\/p>\n<h3>\u56db\u3001which&#xff1a;\u547d\u4ee4&#034;\u85cf&#034;\u5728\u54ea\u4e2a\u76ee\u5f55<\/h3>\n<p>which \u6cbf\u7740 PATH \u73af\u5883\u53d8\u91cf\u91cc\u7684\u76ee\u5f55\u9010\u4e2a\u67e5\u627e&#xff0c;\u8fd4\u56de\u53ef\u6267\u884c\u547d\u4ee4\u7684\u5b8c\u6574\u8def\u5f84\u3002<\/p>\n<h4>\u8bed\u6cd5\u683c\u5f0f<\/h4>\n<p><span class=\"token function\">which<\/span> <span class=\"token punctuation\">[<\/span>\u9009\u9879<span class=\"token punctuation\">]<\/span> \u547d\u4ee4\u540d<\/p>\n<h4>\u5e38\u7528\u53c2\u6570<\/h4>\n<table>\n<tr>\u53c2\u6570\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>-a<\/td>\n<td>\u663e\u793a\u6240\u6709\u5339\u914d\u8def\u5f84&#xff08;PATH \u4e2d\u53ef\u80fd\u6709\u591a\u4e2a\u540c\u540d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>-i<\/td>\n<td>\u5ffd\u7565\u5927\u5c0f\u5199&#xff08;GNU \u7248\u672c&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u793a\u4f8b\u4e0e\u9884\u671f\u8f93\u51fa<\/h4>\n<p>\u793a\u4f8b&#xff1a;\u67e5 python3 \u5728\u54ea\u3001\u662f\u5426\u5df2\u5b89\u88c5<\/p>\n<p><span class=\"token function\">which<\/span> python3<\/p>\n<p>\u9884\u671f\u8f93\u51fa&#xff1a;<\/p>\n<p>\/usr\/bin\/python3<\/p>\n<p>\u5982\u679c\u6ca1\u5b89\u88c5\u5219\u65e0\u8f93\u51fa&#xff08;\u9000\u51fa\u7801\u4e3a 1&#xff09;\u3002\u56e0\u6b64 which \u5e38\u88ab\u5199\u8fdb\u811a\u672c\u505a\u4f9d\u8d56\u68c0\u67e5&#xff1a;<\/p>\n<p><span class=\"token function\">which<\/span> <span class=\"token function\">git<\/span> <span class=\"token operator\">||<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;git \u672a\u5b89\u88c5&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token builtin class-name\">exit<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5c0f\u77e5\u8bc6&#xff1a;which \u53ea\u770b PATH&#xff0c;\u5982\u679c\u67d0\u4e2a\u547d\u4ee4\u662f\u901a\u8fc7\u5b8c\u6574\u8def\u5f84\u8c03\u7528&#xff08;\u5982 \/opt\/app\/bin\/tool&#xff09;&#xff0c;which tool \u662f\u627e\u4e0d\u5230\u7684&#xff0c;\u7528 type -a tool \u6216 find \u515c\u5e95\u3002<\/p>\n<h3>\u4e94\u3001whereis&#xff1a;\u8fde\u6e90\u7801\u548c\u6587\u6863\u4e00\u8d77\u627e<\/h3>\n<p>whereis \u6bd4 which \u66f4\u8fdb\u4e00\u6b65&#xff0c;\u5b83\u4f1a\u53bb\u6807\u51c6\u76ee\u5f55\u641c\u7d22&#xff0c;\u540c\u65f6\u8fd4\u56de\u4e8c\u8fdb\u5236\u3001\u6e90\u7801\u548c man \u624b\u518c\u7684\u4f4d\u7f6e\u3002<\/p>\n<h4>\u8bed\u6cd5\u683c\u5f0f<\/h4>\n<p><span class=\"token function\">whereis<\/span> <span class=\"token punctuation\">[<\/span>\u9009\u9879<span class=\"token punctuation\">]<\/span> \u547d\u4ee4\u540d<\/p>\n<h4>\u5e38\u7528\u53c2\u6570<\/h4>\n<table>\n<tr>\u53c2\u6570\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>-b<\/td>\n<td>\u53ea\u627e\u4e8c\u8fdb\u5236\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>-m<\/td>\n<td>\u53ea\u627e man \u624b\u518c<\/td>\n<\/tr>\n<tr>\n<td>-s<\/td>\n<td>\u53ea\u627e\u6e90\u7801<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u793a\u4f8b\u4e0e\u9884\u671f\u8f93\u51fa<\/h4>\n<p>\u793a\u4f8b&#xff1a;\u67e5 nginx \u7684\u6240\u6709\u76f8\u5173\u6587\u4ef6<\/p>\n<p><span class=\"token function\">whereis<\/span> nginx<\/p>\n<p>\u9884\u671f\u8f93\u51fa&#xff1a;<\/p>\n<p>nginx: \/usr\/sbin\/nginx \/usr\/share\/man\/man8\/nginx.8.gz<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u770b\u67d0\u4e2a\u547d\u4ee4\u7684\u624b\u518c\u4f4d\u7f6e&#xff0c;whereis -m ls \u5c31\u80fd\u7ed9\u51fa \/usr\/share\/man\/man1\/ls.1.gz\u3002<\/p>\n<h3>\u516d\u3001\u77e5\u8bc6\u6269\u5c55&#xff1a;find \u7684 -exec \u4e0e\u7ba1\u9053 xargs \u7684\u53d6\u820d<\/h3>\n<p>find -exec rm -f {} \\\\; \u548c find &#8230; | xargs rm -f \u90fd\u80fd\u6279\u91cf\u5904\u7406\u7ed3\u679c&#xff0c;\u533a\u522b\u5728\u54ea&#xff1f;<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u9879-exec &#8230; \\\\;\u7ba1\u9053 &#043; xargs<\/tr>\n<tbody>\n<tr>\n<td>\u6267\u884c\u65b9\u5f0f<\/td>\n<td>\u6bcf\u4e2a\u6587\u4ef6\u8d77\u4e00\u4e2a\u5b50\u8fdb\u7a0b<\/td>\n<td>\u6279\u91cf\u6253\u5305\u6210\u53c2\u6570&#xff0c;\u4e00\u6b21\u6267\u884c\u591a\u6b21<\/td>\n<\/tr>\n<tr>\n<td>\u5904\u7406\u7279\u6b8a\u6587\u4ef6\u540d<\/td>\n<td>\u5b89\u5168&#xff08;\u9010\u9879\u4f20\u53c2&#xff09;<\/td>\n<td>\u9700\u52a0 -print0 &#043; -0 \u914d\u5408&#xff0c;\u5426\u5219\u7a7a\u683c\/\u6362\u884c\u6587\u4ef6\u540d\u4f1a\u51fa\u9519<\/td>\n<\/tr>\n<tr>\n<td>\u901f\u5ea6<\/td>\n<td>\u6162&#xff08;\u8fdb\u7a0b\u5f00\u9500\u5927&#xff09;<\/td>\n<td>\u5feb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a8\u8350\u505a\u6cd5&#xff1a;\u6587\u4ef6\u540d\u7b80\u5355\u65f6\u7528 xargs&#xff08;\u914d\u5408 -print0 \u66f4\u7a33&#xff09;&#xff0c;\u8ffd\u6c42\u7a33\u59a5\u6216\u6587\u4ef6\u5c11\u65f6\u7528 -exec\u3002\u5173\u4e8e xargs \u7684\u6df1\u5165\u7528\u6cd5&#xff08;-n\u3001-I\u3001-P \u5e76\u884c&#xff09;&#xff0c;\u7b2c 19 \u7bc7\u4e13\u95e8\u5c55\u5f00\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u77e5\u8bc6\u70b9&#xff1a;find \u7684\u6761\u4ef6\u9ed8\u8ba4\u662f AND&#xff08;\u4e0e&#xff09;&#xff0c;\u6bd4\u5982 -name &#034;*.conf&#034; -type f \u8868\u793a\u4e24\u4e2a\u6761\u4ef6\u540c\u65f6\u6ee1\u8db3\u3002\u5982\u679c\u8981\u8868\u8fbe OR&#xff0c;\u7528 -o \u5e76\u914d\u5408\u62ec\u53f7&#xff1a;find \/etc \\\\( -name &#034;*.conf&#034; -o -name &#034;*.ini&#034; \\\\)\u3002\u6ce8\u610f\u62ec\u53f7\u8981\u8f6c\u4e49\u6216\u52a0\u5f15\u53f7&#xff0c;\u5426\u5219 Shell \u4f1a\u628a\u5b83\u5f53\u5b50 shell\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u7bc7&#xff1a;<br \/>\n\u201c\u90a3\u4e2a nginx.conf \u5230\u5e95\u5728\u54ea&#xff1f;\u201d\u2014\u2014\u8fd9\u662f\u6bcf\u4e2a Linux \u65b0\u624b\u548c\u8001\u624b\u90fd\u4f1a\u9047\u5230\u7684\u7075\u9b42\u62f7\u95ee\u3002<br \/>\n\u6709\u4e00\u6b21\u6211\u63a5\u624b\u4e00\u53f0\\&#8221;\u7956\u4f20\\&#8221;\u670d\u52a1\u5668&#xff0c;\u524d\u540c\u4e8b\u628a Nginx \u88c5\u5728\u4e86\u7f16\u8bd1\u76ee\u5f55\u91cc&#xff0c;\u914d\u7f6e\u6587\u4ef6\u65e2\u4e0d\u5728 \/etc\/nginx \u4e5f\u4e0d\u5728 \/usr\/local\/nginx\/conf\u3002\u6211\u7528\u4e86\u4e09\u62db\u5b9a\u4f4d&#xff1a;<br \/>\nwhich nginx            # \u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\u5728\u54ea\u4e2a\u76ee\u5f55<br \/>\nfind \/ -name \\&#8221;nginx.con<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11815,58,43,44],"topic":[],"class_list":["post-106223","post","type-post","status-publish","format-standard","hentry","category-server","tag-11815","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/106223.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5f00\u7bc7&#xff1a; \u201c\u90a3\u4e2a nginx.conf \u5230\u5e95\u5728\u54ea&#xff1f;\u201d\u2014\u2014\u8fd9\u662f\u6bcf\u4e2a Linux \u65b0\u624b\u548c\u8001\u624b\u90fd\u4f1a\u9047\u5230\u7684\u7075\u9b42\u62f7\u95ee\u3002 \u6709\u4e00\u6b21\u6211\u63a5\u624b\u4e00\u53f0&quot;\u7956\u4f20&quot;\u670d\u52a1\u5668&#xff0c;\u524d\u540c\u4e8b\u628a Nginx \u88c5\u5728\u4e86\u7f16\u8bd1\u76ee\u5f55\u91cc&#xff0c;\u914d\u7f6e\u6587\u4ef6\u65e2\u4e0d\u5728 \/etc\/nginx \u4e5f\u4e0d\u5728 \/usr\/local\/nginx\/conf\u3002\u6211\u7528\u4e86\u4e09\u62db\u5b9a\u4f4d&#xff1a; which nginx      # \u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\u5728\u54ea\u4e2a\u76ee\u5f55 find \/ -name &quot;nginx.con\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106223.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-16T14:40:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106223.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106223.html\",\"name\":\"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-16T14:40:29+00:00\",\"dateModified\":\"2026-09-16T14:40:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106223.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106223.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106223.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/106223.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5f00\u7bc7&#xff1a; \u201c\u90a3\u4e2a nginx.conf \u5230\u5e95\u5728\u54ea&#xff1f;\u201d\u2014\u2014\u8fd9\u662f\u6bcf\u4e2a Linux \u65b0\u624b\u548c\u8001\u624b\u90fd\u4f1a\u9047\u5230\u7684\u7075\u9b42\u62f7\u95ee\u3002 \u6709\u4e00\u6b21\u6211\u63a5\u624b\u4e00\u53f0\"\u7956\u4f20\"\u670d\u52a1\u5668&#xff0c;\u524d\u540c\u4e8b\u628a Nginx \u88c5\u5728\u4e86\u7f16\u8bd1\u76ee\u5f55\u91cc&#xff0c;\u914d\u7f6e\u6587\u4ef6\u65e2\u4e0d\u5728 \/etc\/nginx \u4e5f\u4e0d\u5728 \/usr\/local\/nginx\/conf\u3002\u6211\u7528\u4e86\u4e09\u62db\u5b9a\u4f4d&#xff1a; which nginx      # \u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\u5728\u54ea\u4e2a\u76ee\u5f55 find \/ -name \"nginx.con","og_url":"https:\/\/www.wsisp.com\/helps\/106223.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-16T14:40:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106223.html","url":"https:\/\/www.wsisp.com\/helps\/106223.html","name":"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-16T14:40:29+00:00","dateModified":"2026-09-16T14:40:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106223.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106223.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106223.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u67e5\u627e\u6587\u4ef6\u547d\u4ee4\uff1afind\u3001locate\u3001which\u3001whereis\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=106223"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106223\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106223"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}