{"id":6525,"date":"2024-08-29T20:43:24","date_gmt":"2024-08-29T12:43:24","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6525"},"modified":"2024-08-29T20:43:24","modified_gmt":"2024-08-29T12:43:24","slug":"%e5%90%8e%e7%ab%af%e5%bc%80%e5%8f%91%e5%b8%b8%e7%94%a8-linux-%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6525","title":{"rendered":"\u540e\u7aef\u5f00\u53d1\u5e38\u7528 Linux \u547d\u4ee4"},"content":{"rendered":"<blockquote>\n<p>\u975e\u539f\u521b\u3001ChatGPT \u95ee\u7b54\u751f\u6210<\/p>\n<\/blockquote>\n<p>\u5728\u540e\u7aef\u5f00\u53d1\u4e2d\uff0c\u719f\u6089\u5e38\u7528\u7684 Linux \u547d\u4ee4\u5bf9\u4e8e\u7cfb\u7edf\u7ba1\u7406\u3001\u8c03\u8bd5\u548c\u65e5\u5e38\u64cd\u4f5c\u975e\u5e38\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Linux \u547d\u4ee4\u53ca\u5176\u4f5c\u7528\uff1a<\/p>\n<h3>1. <strong>\u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>ls<\/code><\/strong>: \u5217\u51fa\u76ee\u5f55\u5185\u5bb9\u3002<\/p>\n<ul>\n<li><code>ls -l<\/code>\uff1a\u4ee5\u957f\u683c\u5f0f\u663e\u793a\u6587\u4ef6\u548c\u76ee\u5f55\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<li><code>ls -a<\/code>\uff1a\u663e\u793a\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u9690\u85cf\u6587\u4ef6\uff08\u4ee5 . \u5f00\u5934\u7684\u6587\u4ef6\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>cd<\/code><\/strong>: \u5207\u6362\u76ee\u5f55\u3002<\/p>\n<ul>\n<li><code>cd \/path\/to\/directory<\/code>\uff1a\u8fdb\u5165\u6307\u5b9a\u76ee\u5f55\u3002<\/li>\n<li><code>cd ..<\/code>\uff1a\u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>pwd<\/code><\/strong>: \u663e\u793a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u7684\u8def\u5f84\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>cp<\/code><\/strong>: \u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/p>\n<ul>\n<li><code>cp file1 file2<\/code>\uff1a\u590d\u5236 file1 \u5230 file2\u3002<\/li>\n<li><code>cp -r dir1 dir2<\/code>\uff1a\u9012\u5f52\u590d\u5236\u76ee\u5f55 dir1 \u5230 dir2\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>mv<\/code><\/strong>: \u79fb\u52a8\u6216\u91cd\u547d\u540d\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/p>\n<ul>\n<li><code>mv file1 file2<\/code>\uff1a\u5c06 file1 \u79fb\u52a8\u6216\u91cd\u547d\u540d\u4e3a file2\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>rm<\/code><\/strong>: \u5220\u9664\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/p>\n<ul>\n<li><code>rm file<\/code>\uff1a\u5220\u9664\u6307\u5b9a\u6587\u4ef6\u3002<\/li>\n<li><code>rm -r dir<\/code>\uff1a\u9012\u5f52\u5220\u9664\u76ee\u5f55\u53ca\u5176\u5185\u5bb9\u3002<\/li>\n<li><code>rm -f file<\/code>\uff1a\u5f3a\u5236\u5220\u9664\u6587\u4ef6\uff0c\u4e0d\u63d0\u793a\u786e\u8ba4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>touch<\/code><\/strong>: \u521b\u5efa\u7a7a\u6587\u4ef6\u6216\u66f4\u65b0\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4\u3002<\/p>\n<ul>\n<li><code>touch file<\/code>\uff1a\u521b\u5efa\u4e00\u4e2a\u7a7a\u6587\u4ef6\u6216\u66f4\u65b0\u5df2\u6709\u6587\u4ef6\u7684\u65f6\u95f4\u6233\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>2. <strong>\u6587\u4ef6\u5185\u5bb9\u67e5\u770b\u548c\u7f16\u8f91<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>cat<\/code><\/strong>: \u663e\u793a\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<ul>\n<li><code>cat file<\/code>\uff1a\u8f93\u51fa\u6587\u4ef6\u7684\u5185\u5bb9\u5230\u6807\u51c6\u8f93\u51fa\uff08\u7ec8\u7aef\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>less<\/code><\/strong>: \u5206\u9875\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<ul>\n<li><code>less file<\/code>\uff1a\u5206\u9875\u663e\u793a\u6587\u4ef6\u5185\u5bb9\uff0c\u53ef\u4ee5\u5411\u524d\u6216\u5411\u540e\u6eda\u52a8\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>more<\/code><\/strong>: \u5206\u9875\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\uff08\u529f\u80fd\u7c7b\u4f3c\u4e8e <code>less<\/code>\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>head<\/code><\/strong>: \u67e5\u770b\u6587\u4ef6\u7684\u5f00\u5934\u90e8\u5206\u3002<\/p>\n<ul>\n<li><code>head -n 10 file<\/code>\uff1a\u67e5\u770b\u6587\u4ef6\u7684\u524d 10 \u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>tail<\/code><\/strong>: \u67e5\u770b\u6587\u4ef6\u7684\u7ed3\u5c3e\u90e8\u5206\u3002<\/p>\n<ul>\n<li><code>tail -n 10 file<\/code>\uff1a\u67e5\u770b\u6587\u4ef6\u7684\u540e 10 \u884c\u3002<\/li>\n<li><code>tail -f file<\/code>\uff1a\u5b9e\u65f6\u67e5\u770b\u6587\u4ef6\u7684\u8ffd\u52a0\u5185\u5bb9\uff08\u5e38\u7528\u4e8e\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>grep<\/code><\/strong>: \u641c\u7d22\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u3002<\/p>\n<ul>\n<li><code>grep pattern file<\/code>\uff1a\u641c\u7d22\u6587\u4ef6\u4e2d\u5339\u914d\u6a21\u5f0f\u7684\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>nano<\/code><\/strong> \u548c <strong><code>vim<\/code><\/strong>: \u6587\u672c\u7f16\u8f91\u5668\u3002<\/p>\n<ul>\n<li><code>nano file<\/code>\uff1a\u4f7f\u7528 Nano \u7f16\u8f91\u5668\u7f16\u8f91\u6587\u4ef6\u3002<\/li>\n<li><code>vim file<\/code>\uff1a\u4f7f\u7528 Vim \u7f16\u8f91\u5668\u7f16\u8f91\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>3. <strong>\u7cfb\u7edf\u7ba1\u7406<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>top<\/code><\/strong>: \u663e\u793a\u7cfb\u7edf\u7684\u5b9e\u65f6\u8fdb\u7a0b\u548c\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>htop<\/code><\/strong>: \u7c7b\u4f3c\u4e8e <code>top<\/code>\uff0c\u4f46\u63d0\u4f9b\u4e86\u66f4\u53cb\u597d\u7684\u4ea4\u4e92\u5f0f\u754c\u9762\uff08\u9700\u8981\u989d\u5916\u5b89\u88c5\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>ps<\/code><\/strong>: \u663e\u793a\u5f53\u524d\u8fdb\u7a0b\u7684\u72b6\u6001\u3002<\/p>\n<ul>\n<li><code>ps aux<\/code>\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>kill<\/code><\/strong>: \u7ec8\u6b62\u8fdb\u7a0b\u3002<\/p>\n<ul>\n<li><code>kill PID<\/code>\uff1a\u7ec8\u6b62\u6307\u5b9a\u8fdb\u7a0b ID \u7684\u8fdb\u7a0b\u3002<\/li>\n<li><code>kill -9 PID<\/code>\uff1a\u5f3a\u5236\u7ec8\u6b62\u8fdb\u7a0b\uff08SIGKILL \u4fe1\u53f7\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>df<\/code><\/strong>: \u663e\u793a\u6587\u4ef6\u7cfb\u7edf\u7684\u78c1\u76d8\u7a7a\u95f4\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<ul>\n<li><code>df -h<\/code>\uff1a\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u683c\u5f0f\u663e\u793a\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\uff08\u4f8b\u5982\uff0cGB\u3001MB\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>du<\/code><\/strong>: \u663e\u793a\u76ee\u5f55\u6216\u6587\u4ef6\u7684\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<ul>\n<li><code>du -sh \/path\/to\/dir<\/code>\uff1a\u663e\u793a\u6307\u5b9a\u76ee\u5f55\u7684\u603b\u5927\u5c0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>free<\/code><\/strong>: \u663e\u793a\u7cfb\u7edf\u5185\u5b58\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<ul>\n<li><code>free -h<\/code>\uff1a\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u683c\u5f0f\u663e\u793a\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>uptime<\/code><\/strong>: \u663e\u793a\u7cfb\u7edf\u7684\u8fd0\u884c\u65f6\u95f4\u3001\u8d1f\u8f7d\u5747\u8861\u7b49\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>reboot<\/code><\/strong> \u548c <strong><code>shutdown<\/code><\/strong>: \u91cd\u542f\u6216\u5173\u95ed\u7cfb\u7edf\u3002<\/p>\n<ul>\n<li><code>reboot<\/code>\uff1a\u91cd\u542f\u7cfb\u7edf\u3002<\/li>\n<li><code>shutdown -h now<\/code>\uff1a\u7acb\u5373\u5173\u95ed\u7cfb\u7edf\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>4. <strong>\u6743\u9650\u548c\u6240\u6709\u6743<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>chmod<\/code><\/strong>: \u66f4\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002<\/p>\n<ul>\n<li><code>chmod 755 file<\/code>\uff1a\u8bbe\u7f6e\u6587\u4ef6\u6743\u9650\u4e3a rwxr-xr-x\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>chown<\/code><\/strong>: \u66f4\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6240\u6709\u8005\u548c\u7ec4\u3002<\/p>\n<ul>\n<li><code>chown user:group file<\/code>\uff1a\u5c06\u6587\u4ef6\u7684\u6240\u6709\u8005\u548c\u7ec4\u66f4\u6539\u4e3a\u6307\u5b9a\u7684\u7528\u6237\u548c\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>chgrp<\/code><\/strong>: \u66f4\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u7ec4\u3002<\/p>\n<ul>\n<li><code>chgrp group file<\/code>\uff1a\u5c06\u6587\u4ef6\u7684\u7ec4\u66f4\u6539\u4e3a\u6307\u5b9a\u7684\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>5. <strong>\u7f51\u7edc\u7ba1\u7406<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>ifconfig<\/code><\/strong> \u548c <strong><code>ip<\/code><\/strong>: \u67e5\u770b\u548c\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\u3002<\/p>\n<ul>\n<li><code>ifconfig<\/code>\uff1a\u663e\u793a\u6216\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\uff08<code>ifconfig<\/code> \u5df2\u88ab <code>ip<\/code> \u547d\u4ee4\u53d6\u4ee3\uff09\u3002<\/li>\n<li><code>ip addr show<\/code>\uff1a\u663e\u793a\u7f51\u7edc\u63a5\u53e3\u7684 IP \u5730\u5740\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>ping<\/code><\/strong>: \u6d4b\u8bd5\u7f51\u7edc\u8fde\u901a\u6027\u3002<\/p>\n<ul>\n<li><code>ping host<\/code>\uff1a\u5411\u4e3b\u673a\u53d1\u9001 ICMP \u56de\u663e\u8bf7\u6c42\u4ee5\u6d4b\u8bd5\u8fde\u901a\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>netstat<\/code><\/strong> \u548c <strong><code>ss<\/code><\/strong>: \u663e\u793a\u7f51\u7edc\u8fde\u63a5\u3001\u8def\u7531\u548c\u7f51\u7edc\u7edf\u8ba1\u3002<\/p>\n<ul>\n<li><code>netstat -tuln<\/code>\uff1a\u663e\u793a\u76d1\u542c\u7684\u7f51\u7edc\u7aef\u53e3\u548c\u8fde\u63a5\u3002<\/li>\n<li><code>ss -tuln<\/code>\uff1a\u663e\u793a\u66f4\u8be6\u7ec6\u7684\u7f51\u7edc\u8fde\u63a5\u4fe1\u606f\uff08<code>ss<\/code> \u662f <code>netstat<\/code> \u7684\u66ff\u4ee3\u5de5\u5177\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>curl<\/code><\/strong> \u548c <strong><code>wget<\/code><\/strong>: \u4e0b\u8f7d\u6587\u4ef6\u6216\u8fdb\u884c HTTP \u8bf7\u6c42\u3002<\/p>\n<ul>\n<li><code>curl http:\/\/example.com<\/code>\uff1a\u4f7f\u7528 <code>curl<\/code> \u53d1\u8d77 HTTP \u8bf7\u6c42\u3002<\/li>\n<li><code>wget http:\/\/example.com\/file<\/code>\uff1a\u4e0b\u8f7d\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>6. <strong>\u6587\u4ef6\u5f52\u6863\u548c\u538b\u7f29<\/strong><\/h3>\n<ul>\n<li>\n<p><strong><code>tar<\/code><\/strong>: \u6253\u5305\u548c\u89e3\u5305\u6587\u4ef6\u3002<\/p>\n<ul>\n<li><code>tar -cvf archive.tar file1 file2<\/code>\uff1a\u521b\u5efa\u4e00\u4e2a tar \u5f52\u6863\u6587\u4ef6\u3002<\/li>\n<li><code>tar -xvf archive.tar<\/code>\uff1a\u89e3\u5305 tar \u5f52\u6863\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>gzip<\/code><\/strong> \u548c <strong><code>gunzip<\/code><\/strong>: \u538b\u7f29\u548c\u89e3\u538b\u6587\u4ef6\u3002<\/p>\n<ul>\n<li><code>gzip file<\/code>\uff1a\u538b\u7f29\u6587\u4ef6\u3002<\/li>\n<li><code>gunzip file.gz<\/code>\uff1a\u89e3\u538b gzip \u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong><code>zip<\/code><\/strong> \u548c <strong><code>unzip<\/code><\/strong>: \u538b\u7f29\u548c\u89e3\u538b zip \u6587\u4ef6\u3002<\/p>\n<ul>\n<li><code>zip archive.zip file1 file2<\/code>\uff1a\u521b\u5efa\u4e00\u4e2a zip \u5f52\u6863\u6587\u4ef6\u3002<\/li>\n<li><code>unzip archive.zip<\/code>\uff1a\u89e3\u538b zip \u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u547d\u4ee4\u6db5\u76d6\u4e86\u65e5\u5e38\u5f00\u53d1\u4e2d\u53ef\u80fd\u4f1a\u7528\u5230\u7684\u8bb8\u591a\u64cd\u4f5c\u3002\u638c\u63e1\u5b83\u4eec\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u7cfb\u7edf\u3001\u5904\u7406\u6587\u4ef6\u4ee5\u53ca\u8c03\u8bd5\u548c\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u975e\u539f\u521b\u3001ChatGPT \u95ee\u7b54\u751f\u6210 \u5728\u540e\u7aef\u5f00\u53d1\u4e2d\uff0c\u719f\u6089\u5e38\u7528\u7684 Linux \u547d\u4ee4\u5bf9\u4e8e\u7cfb\u7edf\u7ba1\u7406\u3001\u8c03\u8bd5\u548c\u65e5\u5e38\u64cd\u4f5c\u975e\u5e38\u91cd&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6525\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[155],"class_list":["post-6525","post","type-post","status-publish","format-standard","hentry","category-123","tag-linux"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6525"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6525\/revisions"}],"predecessor-version":[{"id":6526,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6525\/revisions\/6526"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}