{"id":395,"date":"2026-10-08T18:04:28","date_gmt":"2026-10-08T10:04:28","guid":{"rendered":"https:\/\/arche.bond\/?p=395"},"modified":"2026-10-08T18:21:35","modified_gmt":"2026-10-08T10:21:35","slug":"linux%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/arche.bond\/?p=395","title":{"rendered":"Linux\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"\n<iframe frameborder=\"no\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" width=330 height=110 src=\"\/\/music.163.com\/outchain\/player?type=0&#038;id=14438717270&#038;auto=1&#038;height=90\"><\/iframe>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><h2>\u4e00\u3001\u8ba4\u8bc6\u4f60\u7684\u4f4d\u7f6e\u548c\u73af\u5883<\/h2>\n<pre><code class=\"language-bash\">pwd                 # \u6211\u5728\u54ea\u4e2a\u76ee\u5f55\nwhoami              # \u6211\u662f\u8c01\nhostname            # \u4e3b\u673a\u540d\nuname -a            # \u5185\u6838\u548c\u7cfb\u7edf\u4fe1\u606f\nuptime              # \u5f00\u673a\u591a\u4e45\u3001\u8d1f\u8f7d\ndate                # \u5f53\u524d\u65f6\u95f4\n<\/code><\/pre>\n<h2>\u4e8c\u3001\u76ee\u5f55\u4e0e\u6587\u4ef6\uff08\u6700\u6838\u5fc3\uff09<\/h2>\n<pre><code class=\"language-bash\">ls                  # \u5217\u51fa\u6587\u4ef6\nls -l               # \u957f\u683c\u5f0f\uff08\u5c31\u662f ll\uff09\nls -la              # \u542b\u9690\u85cf\u6587\u4ef6\ncd \/etc             # \u8fdb\u5165\u76ee\u5f55\ncd ..               # \u8fd4\u56de\u4e0a\u4e00\u7ea7\ncd ~                # \u56de\u5230\u5bb6\u76ee\u5f55\ncd -                # \u56de\u5230\u4e0a\u6b21\u6240\u5728\u76ee\u5f55\nmkdir test          # \u521b\u5efa\u76ee\u5f55\nmkdir -p a\/b\/c      # \u9012\u5f52\u521b\u5efa\u591a\u7ea7\u76ee\u5f55\ntouch a.txt         # \u521b\u5efa\u7a7a\u6587\u4ef6\ncp a.txt b.txt      # \u590d\u5236\ncp -r dir1 dir2     # \u9012\u5f52\u590d\u5236\u76ee\u5f55\nmv a.txt \/tmp\/      # \u79fb\u52a8\/\u91cd\u547d\u540d\nrm a.txt            # \u5220\u9664\u6587\u4ef6\nrm -r dir           # \u9012\u5f52\u5220\u9664\u76ee\u5f55\nrm -rf dir          # \u5f3a\u5236\u9012\u5f52\u5220\u9664\uff08\u5371\u9669\uff01\uff09\n<\/code><\/pre>\n<blockquote>\n<p>\u26a0\ufe0f <code>rm -rf<\/code> \u662f Linux \u6700\u5371\u9669\u7684\u547d\u4ee4\u4e4b\u4e00\uff0c\u5c24\u5176\u4f60\u662f root\uff0c\u5220\u9519\u5c31\u6ca1\u4e86\u3002<strong>\u5148 <code>ls<\/code> \u786e\u8ba4\u518d\u5220\u3002<\/strong><\/p>\n<\/blockquote>\n<h2>\u4e09\u3001\u67e5\u770b\u6587\u4ef6\u5185\u5bb9<\/h2>\n<pre><code class=\"language-bash\">cat a.txt           # \u5168\u90e8\u6253\u5370\nless a.txt          # \u5206\u9875\u67e5\u770b\uff08q \u9000\u51fa\uff0c\/\u641c\u7d22\uff09\nhead -n 20 a.txt    # \u524d 20 \u884c\ntail -n 20 a.txt    # \u540e 20 \u884c\ntail -f log.txt     # \u5b9e\u65f6\u8ddf\u8e2a\u65e5\u5fd7\uff08Ctrl+C \u9000\u51fa\uff09\nwc -l a.txt         # \u7edf\u8ba1\u884c\u6570\n<\/code><\/pre>\n<h2>\u56db\u3001\u67e5\u627e\u4e0e\u641c\u7d22<\/h2>\n<pre><code class=\"language-bash\">find \/etc -name &quot;*.conf&quot;        # \u6309\u540d\u5b57\u627e\u6587\u4ef6\nfind . -type d                  # \u53ea\u627e\u76ee\u5f55\ngrep &quot;error&quot; log.txt            # \u5728\u6587\u4ef6\u91cc\u641c\u5185\u5bb9\ngrep -r &quot;hello&quot; \/etc            # \u9012\u5f52\u641c\u7d22\u76ee\u5f55\ngrep -i &quot;error&quot; log.txt         # \u5ffd\u7565\u5927\u5c0f\u5199\nwhich apt                       # \u547d\u4ee4\u7684\u53ef\u6267\u884c\u6587\u4ef6\u5728\u54ea\nwhereis apt                     # \u547d\u4ee4\u76f8\u5173\u7684\u6587\u4ef6\u4f4d\u7f6e\n<\/code><\/pre>\n<h2>\u4e94\u3001\u6743\u9650\u4e0e\u7528\u6237<\/h2>\n<pre><code class=\"language-bash\">ls -l a.txt         # \u770b\u6743\u9650\uff1a-rw-r--r--\nchmod 755 a.sh      # \u6539\u6743\u9650\uff08r=4 w=2 x=1\uff09\nchmod +x a.sh       # \u52a0\u53ef\u6267\u884c\u6743\u9650\nchown user:user a.txt   # \u6539\u5c5e\u4e3b\u5c5e\u7ec4\nuseradd tom         # \u65b0\u5efa\u7528\u6237\npasswd tom          # \u7ed9\u7528\u6237\u8bbe\u5bc6\u7801\nsu - tom            # \u5207\u6362\u7528\u6237\nsudo command        # \u4ee5 root \u6267\u884c\uff08\u4f60\u5df2\u662f root\uff0c\u53ef\u4e0d\u7528\uff09\n<\/code><\/pre>\n<h2>\u516d\u3001\u8fdb\u7a0b\u4e0e\u7cfb\u7edf\u8d44\u6e90<\/h2>\n<pre><code class=\"language-bash\">ps aux              # \u6240\u6709\u8fdb\u7a0b\nps aux | grep nginx # \u8fc7\u6ee4\u8fdb\u7a0b\ntop                 # \u5b9e\u65f6\u8d44\u6e90\u76d1\u63a7\uff08q \u9000\u51fa\uff09\nhtop                # \u66f4\u597d\u770b\u7684 top\uff08\u9700\u5b89\u88c5\uff09\nkill 1234           # \u7ed3\u675f PID \u4e3a 1234 \u7684\u8fdb\u7a0b\nkill -9 1234        # \u5f3a\u5236\u7ed3\u675f\nfree -h             # \u5185\u5b58\u4f7f\u7528\ndf -h               # \u78c1\u76d8\u4f7f\u7528\ndu -sh \/var\/log     # \u67d0\u76ee\u5f55\u5360\u7528\u5927\u5c0f\n<\/code><\/pre>\n<h2>\u4e03\u3001\u7f51\u7edc<\/h2>\n<pre><code class=\"language-bash\">ip a                # \u67e5\u770b IP\uff08\u65b0\u7248\uff09\nip -br -c a         # \u7b80\u6d01\u5e26\u989c\u8272\nping baidu.com      # \u6d4b\u8bd5\u8fde\u901a\ncurl https:\/\/baidu.com     # \u53d1 HTTP \u8bf7\u6c42\nwget https:\/\/xxx\/file      # \u4e0b\u8f7d\u6587\u4ef6\nss -tulnp           # \u67e5\u770b\u76d1\u542c\u7aef\u53e3\nnetstat -tulnp      # \u8001\u547d\u4ee4\uff08\u53ef\u80fd\u9700\u5b89\u88c5\uff09\n<\/code><\/pre>\n<h2>\u516b\u3001\u8f6f\u4ef6\u5305\uff08apt\uff09<\/h2>\n<pre><code class=\"language-bash\">apt update                  # \u66f4\u65b0\u6e90\u7d22\u5f15\napt upgrade -y              # \u5347\u7ea7\u5df2\u88c5\u8f6f\u4ef6\napt install tree -y         # \u5b89\u88c5\napt remove tree             # \u5378\u8f7d\napt purge tree              # \u5378\u8f7d+\u6e05\u914d\u7f6e\napt search nginx            # \u641c\u7d22\napt show nginx              # \u67e5\u770b\u8be6\u60c5\napt list --installed        # \u5df2\u5b89\u88c5\u5217\u8868\napt autoremove              # \u6e05\u7406\u65e0\u7528\u4f9d\u8d56\n<\/code><\/pre>\n<h2>\u4e5d\u3001\u538b\u7f29\u4e0e\u89e3\u538b<\/h2>\n<pre><code class=\"language-bash\">tar -czvf a.tar.gz dir\/     # \u6253\u5305\u538b\u7f29\ntar -xzvf a.tar.gz          # \u89e3\u538b\nzip -r a.zip dir\/           # zip \u538b\u7f29\nunzip a.zip                 # \u89e3\u538b zip\n<\/code><\/pre>\n<h2>\u5341\u3001\u7ba1\u9053\u4e0e\u91cd\u5b9a\u5411\uff08\u8fdb\u9636\u5173\u952e\uff09<\/h2>\n<pre><code class=\"language-bash\">command &gt; file      # \u8f93\u51fa\u8986\u76d6\u5230\u6587\u4ef6\ncommand &gt;&gt; file     # \u8f93\u51fa\u8ffd\u52a0\u5230\u6587\u4ef6\ncommand 2&gt; err.txt  # \u9519\u8bef\u8f93\u51fa\u5230\u6587\u4ef6\ncommand | grep x    # \u7ba1\u9053\uff1a\u524d\u4e00\u4e2a\u7684\u8f93\u51fa\u7ed9\u540e\u4e00\u4e2a\nps aux | grep nginx | wc -l   # \u7ec4\u5408\u4f7f\u7528\n<\/code><\/pre>\n<h2>\u5341\u4e00\u3001\u6743\u9650\u63d0\u5347\u4e0e\u5b9a\u65f6\u4efb\u52a1<\/h2>\n<pre><code class=\"language-bash\">crontab -e          # \u7f16\u8f91\u5b9a\u65f6\u4efb\u52a1\ncrontab -l          # \u67e5\u770b\u5b9a\u65f6\u4efb\u52a1\nsystemctl status nginx      # \u67e5\u770b\u670d\u52a1\u72b6\u6001\nsystemctl start nginx       # \u542f\u52a8\u670d\u52a1\nsystemctl enable nginx      # \u5f00\u673a\u81ea\u542f\njournalctl -u nginx -f      # \u770b\u670d\u52a1\u65e5\u5fd7\n<\/code><\/pre>\n<h2>\u5341\u4e8c\u3001\u67e5\u770b\u5e2e\u52a9\uff08\u6700\u91cd\u8981\uff09<\/h2>\n<pre><code class=\"language-bash\">man ls              # \u67e5\u770b\u624b\u518c\uff08q \u9000\u51fa\uff09\nls --help           # \u5feb\u901f\u5e2e\u52a9\nhistory             # \u5386\u53f2\u547d\u4ee4\nhistory | grep apt  # \u641c\u5386\u53f2\u547d\u4ee4\n!!                  # \u91cd\u590d\u4e0a\u4e00\u6761\u547d\u4ee4\n<\/code><\/pre>\n<hr>\n<h2>\u5efa\u8bae\u7684\u5b66\u4e60\u8def\u5f84<\/h2>\n<ol>\n<li><strong>\u5148\u7ec3\u524d\u56db\u90e8\u5206<\/strong>\uff1a<code>pwd \/ ls \/ cd \/ mkdir \/ cp \/ mv \/ rm \/ cat \/ less \/ grep \/ find<\/code>\uff0c\u8fd9\u4e9b\u662f\u6bcf\u5929\u90fd\u8981\u7528\u7684\u3002<\/li>\n<li><strong>\u518d\u5b66\u7b2c\u4e94\u3001\u516d\u90e8\u5206<\/strong>\uff1a\u6743\u9650\u548c\u8fdb\u7a0b\uff0c\u662f\u8fd0\u7ef4\u7684\u57fa\u7840\u3002<\/li>\n<li><strong>\u7136\u540e\u5b66\u7b2c\u4e03\u3001\u516b\u90e8\u5206<\/strong>\uff1a\u7f51\u7edc\u548c apt\uff0c\u4e91\u670d\u52a1\u5668\u4e0a\u6700\u5e38\u7528\u3002<\/li>\n<li><strong>\u6700\u540e\u5b66\u7b2c\u5341\u3001\u5341\u4e00\u90e8\u5206<\/strong>\uff1a\u7ba1\u9053\u3001\u91cd\u5b9a\u5411\u3001systemd\u3001cron\uff0c\u8fd9\u662f\u4ece\u201c\u4f1a\u7528\u201d\u5230\u201c\u4f1a\u7ba1\u201d\u7684\u5206\u6c34\u5cad\u3002<\/li>\n<\/ol>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":353,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/arche.bond\/wp-content\/uploads\/2026\/09\/banner-01.jpg","_links":{"self":[{"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arche.bond\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395"}],"version-history":[{"count":6,"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions\/406"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arche.bond\/index.php?rest_route=\/wp\/v2\/media\/353"}],"wp:attachment":[{"href":"https:\/\/arche.bond\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arche.bond\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arche.bond\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}