{"id":229,"date":"2024-06-21T23:39:44","date_gmt":"2024-06-21T15:39:44","guid":{"rendered":"https:\/\/www1.bonian.qzz.io\/?p=229"},"modified":"2026-10-22T23:50:42","modified_gmt":"2026-10-22T15:50:42","slug":"linux%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www1.bonian.qzz.io\/?p=229","title":{"rendered":"Linux\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"<p><![ 2024-06-21]\/><br \/>\nLinux\u5e38\u7528\u547d\u4ee4<\/p>\n<p>1) \u5173\u673a\/\u91cd\u542f\/\u6ce8\u9500<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nshutdown -h now \u5373\u523b\u5173\u673a<br \/>\nshutdown \u2013r now \u73b0\u5728\u91cd\u65b0\u542f\u52a8\u8ba1\u7b97\u673a<br \/>\nreboot \u73b0\u5728\u91cd\u65b0\u542f\u52a8\u8ba1\u7b97\u673a<\/p>\n<p>2) \u7cfb\u7edf\u4fe1\u606f\u548c\u6027\u80fd\u67e5\u770b<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nhostname \u67e5\u770b\u8ba1\u7b97\u673a\u540d(\u4e3b\u673a\u540d)<br \/>\nwho \u663e\u793a\u5f53\u524d\u767b\u5f55\u7cfb\u7edf\u7684\u2f64\u6237<br \/>\nwho am i \u663e\u793a\u767b\u5f55\u65f6\u7684\u2f64\u6237\u540d<br \/>\nwhoami \u663e\u793a\u5f53\u524d\u2f64\u6237\u540d<br \/>\ncat \/proc\/version \u67e5\u770blinux\u7248\u672c\u4fe1\u606f<br \/>\ncat \/proc\/cpuinfo \u67e5\u770bCPU\u4fe1\u606f<br \/>\ncat \/proc\/interrupts \u67e5\u770b\u4e2d\u65ad<br \/>\ncat \/proc\/loadavg \u67e5\u770b\u7cfb\u7edf\u8d1f\u8f7d<\/p>\n<p>3) \u2f64\u6237\u548c\u2f64\u6237\u7ec4<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nuseradd \u7528\u6237\u540d \u521b\u5efa\u2f64\u6237<br \/>\npasswd \u7528\u6237\u540d \u4fee\u6539\u5bc6\u7801<br \/>\nuserdel -r \u7528\u6237\u540d \u5220\u9664\u2f64\u6237<br \/>\nid \u7528\u6237\u540d \u67e5\u8be2\u7528\u6237\u4fe1\u606f<br \/>\nsu \u5207\u6362\u7528\u6237\u540d \u5207\u6362\u7528\u6237<br \/>\ngroupadd \u7ec4\u540d \u521b\u5efa\u2f64\u6237\u7ec4<br \/>\ngroupdel \u7ec4\u540d \u5220\u9664\u2f64\u6237\u7ec4<br \/>\ngroupmod -n \u65b0\u7ec4\u540d \u65e7\u7ec4\u540d \u91cd\u547d\u540d\u2f64\u6237\u7ec4<br \/>\nusermod -g \u7528\u6237\u7ec4 \u7528\u6237\u540d \u4fee\u6539\u7528\u6237\u7684\u7528\u6237\u7ec4<br \/>\nusermod -aG \u7528\u6237\u7ec4 \u7528\u6237\u540d \u5c06\u2f64\u6237\u6dfb\u52a0\u5230\u7ec4<br \/>\ngroups \u7528\u6237\u540d \u67e5\u770b\u2f64\u6237\u6240\u5728\u7684\u7ec4<br \/>\nw \u67e5\u770b\u6d3b\u52a8\u2f64\u6237<br \/>\nid \u7528\u6237\u540d \u67e5\u770b\u6307\u5b9a\u2f64\u6237\u4fe1\u606f<br \/>\nlast \u67e5\u770b\u2f64\u6237\u767b\u5f55\u2f47\u5fd7<br \/>\ncrontab -l \u67e5\u770b\u5f53\u524d\u2f64\u6237\u7684\u8ba1\u5212\u4efb\u52a1<br \/>\ncut -d: -f1 \/etc\/passwd \u67e5\u770b\u7cfb\u7edf\u6240\u6709\u2f64\u6237<br \/>\ncut -d: -f1 \/etc\/group \u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7ec4<\/p>\n<p>4) \u2f79\u7edc\u548c\u8fdb\u7a0b\u7ba1\u7406<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nifconfig \u67e5\u770b\u2f79\u7edc\u63a5\u2f1d\u5c5e\u6027<br \/>\nnetstat -lntp \u67e5\u770b\u6240\u6709\u76d1\u542c\u7aef\u2f1d<br \/>\nnetstat -antp \u67e5\u770b\u5df2\u7ecf\u5efa\u2f74\u7684TCP\u8fde\u63a5<br \/>\nnetstat -lutp \u67e5\u770bTCP\/UDP\u7684\u72b6\u6001\u4fe1\u606f<br \/>\nps -ef \u67e5\u770b\u6240\u6709\u8fdb\u7a0b<br \/>\nps -ef | grep \u8fdb\u7a0b\u540d\u79f0 \u8fc7\u6ee4\u51fa\u4f60\u9700\u8981\u7684\u8fdb\u7a0b<br \/>\nnetstat -lntp | grep \u7aef\u53e3\u53f7 \u67e5\u8be2\u7aef\u53e3\u7684\u76d1\u542c\u60c5\u51b5<br \/>\ntop \u5b9e\u65f6\u663e\u793a\u8fdb\u7a0b\u72b6\u6001<br \/>\nkill -9 \u8fdb\u7a0b\u53f7 \u901a\u8fc7\u8fdb\u7a0b\u53f7\u6740\u6b7b\u8fdb\u7a0b\/\u7ec8\u6b62\u8fdb\u7a0b<\/p>\n<p>5) \u2f42\u4ef6\u548c\u2f6c\u5f55\u64cd\u4f5c<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\ncd <\u2f6c\u5f55\u540d> \u8fdb\u2f0a\u67d0\u4e2a\u2f6c\u5f55<br \/>\ncd \u2026 \u8fd4\u56de\u56de\u4e0a\u7ea7\u2f6c\u5f55<br \/>\ncd \u8fdb\u4e2a\u2f08\u4e3b\u2f6c\u5f55<br \/>\ncd &#8211; \u56de\u4e0a\u2f00\u6b65\u6240\u5728\u2f6c\u5f55<br \/>\npwd \u663e\u793a\u5f53\u524d\u8def\u5f84<br \/>\nls \u67e5\u770b\u2f42\u4ef6\u2f6c\u5f55\u5217\u8868<br \/>\nll \u67e5\u770b\u2f42\u4ef6\u548c\u2f6c\u5f55\u7684\u8be6\u60c5\u5217\u8868<br \/>\nls -a \u67e5\u770b\u9690\u85cf\u2f42\u4ef6<br \/>\ntree \u67e5\u770b\u2f42\u4ef6\u548c\u2f6c\u5f55\u7684\u6811\u5f62\u7ed3\u6784<br \/>\nmkdir <\u2f6c\u5f55\u540d> \u521b\u5efa\u2f6c\u5f55<br \/>\nrm -f file1(\u6587\u4ef6) \u5220\u9664\u2019file1\u2019\u2f42\u4ef6<br \/>\nrmdir dir1(\u6587\u4ef6\u5939) \u5220\u9664\u2019dir1\u2019\u2f6c\u5f55<br \/>\nrm -rf \u8981\u5220\u9664\u7684\u6587\u4ef6\u6216\u76ee\u5f55 \u5168\u90e8\u5f3a\u5236\u5220\u9664<br \/>\ncp file1 file2 \u590d\u5236\u2f42\u4ef6<br \/>\ncp dir\/* . \u590d\u5236\u67d0\u2f6c\u5f55\u4e0b\u7684\u6240\u6709\u2f42\u4ef6\u2f84\u5f53\u524d\u2f6c\u5f55<br \/>\ncp -a dir1 dir2 \u590d\u5236\u2f6c\u5f55<br \/>\ncp -a \/tmp\/dir1 . \u590d\u5236\u2f00\u4e2a\u2f6c\u5f55\u2f84\u5f53\u524d\u2f6c\u5f55<br \/>\nmv \u6e90\u6587\u4ef6\u6216\u76ee\u5f55 \u76ee\u6807\u6587\u4ef6\u6216\u76ee\u5f55 \u79fb\u52a8\u6587\u4ef6\u6216\u8005\u5c06\u6587\u4ef6\u6539\u540d<br \/>\nfind \/ -name \u6587\u4ef6\u540d \u4ece\u8ddf\u2f6c\u5f55\u5f00\u59cb\u641c\u7d22\u2f42\u4ef6\/\u2f6c\u5f55<br \/>\nfind \/ -user user1 \u641c\u7d22\u2f64\u6237user1\u7684\u2f42\u4ef6\/\u2f6c\u5f55<br \/>\nchmod ugo+rwx \u76ee\u5f55 \u8bbe\u7f6e\u2f6c\u5f55\u6240\u6709\u8005(u)\u3001\u7fa4\u7ec4(g)\u53ca\u5176\u4ed6\u2f08(o) \u7684\u8bfb\u00ae\u3001\u5199(w)\u3001\u6267\u2f8f(x)\u6743\u9650<br \/>\nchmod go-rwx \u76ee\u5f55 \u79fb\u9664\u7fa4\u7ec4(g)\u4e0e\u5176\u4ed6\u2f08(o)\u5bf9\u2f6c\u5f55\u7684\u8bfb\u5199\u6267\u2f8f\u6743\u9650<br \/>\nchown \u7528\u6237\u540d \u6587\u4ef6 \u6539\u53d8\u2f42\u4ef6\u7684\u6240\u6709\u8005\u5c5e\u6027<br \/>\nchown -R \u7528\u6237\u540d \u76ee\u5f55 \u6539\u53d8\u2f6c\u5f55\u7684\u6240\u6709\u8005\u5c5e\u6027<br \/>\nchgrp \u7528\u6237\u7ec4 \u6587\u4ef6 \u6539\u53d8\u2f42\u4ef6\u7fa4\u7ec4<br \/>\nchown \u7528\u6237\u540d:\u7528\u6237\u7ec4 \u6587\u4ef6 \u6539\u53d8\u2f42\u4ef6\u7684\u6240\u6709\u2f08\u548c\u7fa4\u7ec4<\/p>\n<p>6) \u2f42\u4ef6\u67e5\u770b\u548c\u5904\u7406<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\ncat \u6587\u4ef6 \u67e5\u770b\u2f42\u4ef6\u5185\u5bb9<br \/>\ncat -n \u6587\u4ef6 \u67e5\u770b\u5185\u5bb9\u5e76\u6807\u793a\u2f8f\u6570<br \/>\ntac \u6587\u4ef6 \u4ece\u6700\u540e\u2f00\u2f8f\u5f00\u59cb\u53cd\u770b\u2f42\u4ef6\u5185\u5bb9<br \/>\nmore \u6587\u4ef6 \u67e5\u770b\u2f00\u4e2a\u2ed3\u2f42\u4ef6\u7684\u5185\u5bb9<br \/>\nless \u6587\u4ef6 \u7c7b\u4f3cmore\u547d\u4ee4\uff0c\u4f46\u5141\u8bb8\u53cd\u5411\u64cd\u4f5c<br \/>\nhead -2 \u6587\u4ef6 \u67e5\u770b\u2f42\u4ef6\u524d\u4e24\u2f8f<br \/>\ntail -2 \u6587\u4ef6 \u67e5\u770b\u2f42\u4ef6\u540e\u4e24\u2f8f<br \/>\ncomm -1 file1 file2 \u2f50\u8f83\u4e24\u4e2a\u2f42\u4ef6\u7684\u5185\u5bb9(\u53bb\u9664\u2019file1\u2019\u6240\u542b\u5185\u5bb9)<br \/>\ncomm -2 file1 file2 \u2f50\u8f83\u4e24\u4e2a\u2f42\u4ef6\u7684\u5185\u5bb9(\u53bb\u9664\u2019file2\u2019\u6240\u542b\u5185\u5bb9<br \/>\ncomm -3 file1 file2 \u2f50\u8f83\u4e24\u4e2a\u2f42\u4ef6\u7684\u5185\u5bb9(\u53bb\u9664\u4e24\u2f42\u4ef6\u5171\u6709\u90e8\u5206)<\/p>\n<p>7) \u6253\u5305\u548c\u89e3\u538b<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nzip xxx.zip \u8981\u538b\u7f29\u7684\u6587\u4ef6 \u538b\u7f29\u2f84zip\u5305<br \/>\nzip -r xxx.zip \u6587\u4ef61 \u6587\u4ef62 \u76ee\u5f55 \u5c06\u591a\u4e2a\u2f42\u4ef6+\u2f6c\u5f55\u538b\u6210zip\u5305<br \/>\nunzip xxx.zip \u89e3\u538bzip\u5305<br \/>\ntar -cvf xxx.tar \u8981\u538b\u7f29\u7684\u6587\u4ef6 \u521b\u5efa\u2fae\u538b\u7f29tar\u5305<br \/>\ntar -cvf xxx.tar \u6587\u4ef61 \u6587\u4ef62 \u76ee\u5f55 \u5c06\u591a\u4e2a\u2f42\u4ef6+\u2f6c\u5f55\u6253tar\u5305<br \/>\ntar -tf xxx.tar \u67e5\u770btar\u5305\u7684\u5185\u5bb9<br \/>\ntar -xvf xxx.tar \u89e3\u538btar\u5305<br \/>\ntar -xvf xxx.tar -C \u6307\u5b9a\u76ee\u5f55 \u5c06tar\u5305\u89e3\u538b\u2f84\u6307\u5b9a\u2f6c\u5f55<br \/>\ntar -cvfj xxx.tar.bz2 \u8981\u538b\u7f29\u7684\u76ee\u5f55 \u521b\u5efabz2\u538b\u7f29\u5305<br \/>\ntar -jxvf xxx.tar.bz2 \u89e3\u538bbz2\u538b\u7f29\u5305<br \/>\ntar -czvf xxx.tar.gz \u8981\u538b\u7f29\u7684\u76ee\u5f55 \u521b\u5efagzip\u538b\u7f29\u5305<br \/>\ntar -xzvf xxx.tar.gz \u89e3\u538bgzip\u538b\u7f29\u5305<br \/>\nbunzip2 xxx.bz2 \u89e3\u538bbz2\u538b\u7f29\u5305<br \/>\nbzip2 filename \u538b\u7f29\u2f42\u4ef6<br \/>\ngunzip xxx.gz \u89e3\u538bgzip\u538b\u7f29\u5305<br \/>\ngzip filename \u538b\u7f29\u2f42\u4ef6<br \/>\ngzip -9 filename \u6700\u2f24\u7a0b\u5ea6\u538b\u7f29<\/p>\n<p>8) \u9632\u706b\u5899<br \/>\n\u5e38\u7528\u547d\u4ee4 \u4f5c\u7528<br \/>\nsystemctl start firewalld \u542f\u52a8<br \/>\nsystemctl stop firewalld \u5173\u95ed<br \/>\nsystemctl status firewalld \u67e5\u770b\u72b6\u6001<br \/>\nsystemctl disable firewalld \u7981\u7528<br \/>\nfirewall-cmd &#8211;zone=public &#8211;list-ports \u67e5\u770b\u6240\u6709\u6253\u5f00\u7684\u7aef\u53e3<br \/>\nfirewall-cmd &#8211;zone=public &#8211;add-port=80\/tcp &#8211;permanent<br \/>\n(\u2013permanent\u6c38\u4e45\u751f\u6548\uff0c\u6ca1\u6709\u6b64\u53c2\u6570\u91cd\u542f\u540e\u5931\u6548) \u5f00\u542f80\u7aef\u53e3<br \/>\nfirewall-cmd &#8211;zone= public &#8211;remove-port=80\/tcp &#8211;permanent \u5173\u95ed80\u7aef\u53e3<br \/>\nfirewall-cmd &#8211;zone= &#8211;query-port=80\/tcp \u67e5\u770b80\u7aef\u53e3\u662f\u5426\u5f00\u653e<br \/>\nfirewall-cmd &#8211;reload \u91cd\u65b0\u8f7d\u5165<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u5e38\u7528\u547d\u4ee4 1) \u5173\u673a\/\u91cd\u542f\/\u6ce8\u9500 \u5e38\u7528\u547d\u4ee4 \u4f5c\u7528 shutdown -h now \u5373\u523b\u5173\u673a shut &#8230; <a title=\"Linux\u5e38\u7528\u547d\u4ee4\" class=\"read-more\" href=\"https:\/\/www1.bonian.qzz.io\/?p=229\" aria-label=\"Read more about Linux\u5e38\u7528\u547d\u4ee4\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-229","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=229"}],"version-history":[{"count":1,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/posts\/229\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=\/wp\/v2\/posts\/229\/revisions\/233"}],"wp:attachment":[{"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www1.bonian.qzz.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}