{"id":77148,"date":"2026-02-24T01:17:22","date_gmt":"2026-02-23T17:17:22","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/77148.html"},"modified":"2026-02-24T01:17:22","modified_gmt":"2026-02-23T17:17:22","slug":"linux-%e5%b8%b8%e7%94%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/77148.html","title":{"rendered":"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4"},"content":{"rendered":"<p>\u672c\u6587\u6574\u7406\u4e86\u4e00\u4e9b\u81ea\u5df1\u5e38\u7528\u7684 \u670d\u52a1\u5668\u547d\u4ee4\u6e05\u5355&#xff0c;\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001\u8fdb\u7a0b\u7ba1\u7406\u3001\u7f51\u7edc\u6392\u67e5\u3001\u6743\u9650\u63a7\u5236\u3001\u65e5\u5fd7\u5206\u6790\u7b49\u6838\u5fc3\u5185\u5bb9\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c<\/h3>\n<h4>1. \u67e5\u770b\u76ee\u5f55\u5185\u5bb9<\/h4>\n<p>ls# \u67e5\u770b\u76ee\u5f55\u5185\u5bb9<br \/>\nls -l# \u8be6\u7ec6\u4fe1\u606f<br \/>\nls -lh# \u53cb\u597d\u663e\u793a\u6587\u4ef6\u5927\u5c0f<br \/>\nls -a# \u663e\u793a\u9690\u85cf\u6587\u4ef6<\/p>\n<hr \/>\n<h4>2. \u5207\u6362\u76ee\u5f55<\/h4>\n<p>cd \/home# \u5207\u6362\u5230\u6307\u5b9a\u76ee\u5f55<br \/>\ncd ..# \u8fd4\u56de\u4e0a\u4e00\u7ea7<br \/>\ncd ~# \u56de\u5230\u7528\u6237\u76ee\u5f55<\/p>\n<hr \/>\n<h4>3. \u521b\u5efa\u548c\u5220\u9664<\/h4>\n<li>\u521b\u5efa&#xff1a;<\/li>\n<p>mkdir test           # \u521b\u5efa\u76ee\u5f55<br \/>\nmkdir -p a\/b\/c       # \u9012\u5f52\u521b\u5efa\u76ee\u5f55<\/p>\n<p>-p \u8868\u793a\u9012\u5f52\u521b\u5efa\u76ee\u5f55&#xff0c;\u5982\u679c\u4e0a\u7ea7\u76ee\u5f55\u4e0d\u5b58\u5728&#xff0c;\u4f1a\u81ea\u52a8\u5e2e\u4f60\u521b\u5efa&#xff0c;\u5982\u679c\u76ee\u5f55\u5df2\u7ecf\u5b58\u5728&#xff0c;\u4e5f\u4e0d\u4f1a\u62a5\u9519<\/p>\n<li>\u5220\u9664&#xff1a;<\/li>\n<p>rm file.txt          # \u5220\u9664\u6587\u4ef6<br \/>\nrm -r test           # \u5220\u9664\u76ee\u5f55<br \/>\nrm -rf test          # \u5f3a\u5236\u5220\u9664&#xff08;\u614e\u7528&#xff09;<\/p>\n<p>\u26a0\ufe0f \u5c3d\u91cf\u907f\u514d\u76f4\u63a5\u4f7f\u7528 rm -rf \/ \u8fd9\u79cd\u9ad8\u5371\u547d\u4ee4\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6587\u4ef6\u67e5\u770b\u4e0e\u7f16\u8f91<\/h3>\n<h4>1. \u67e5\u770b\u6587\u4ef6\u5185\u5bb9<\/h4>\n<p>cat file.txt<br \/>\nmore file.txt<br \/>\nless file.txt<br \/>\n# \u6309\u5185\u5bb9\u8fc7\u6ee4\u65e5\u5fd7<br \/>\ngrep &#034;2026-02-21 10:&#034; app.log<\/p>\n<p>\u63a8\u8350\u4f7f\u7528 less&#xff0c;\u652f\u6301\u4e0a\u4e0b\u7ffb\u9875\u3002<\/p>\n<hr \/>\n<h4>2. \u5b9e\u65f6\u67e5\u770b\u65e5\u5fd7&#xff08;\u975e\u5e38\u91cd\u8981&#xff09;<\/h4>\n<p>tail -f -n 100 app.log<br \/>\ntail -f app.log | grep &#039;\u7b5b\u9009\u5185\u5bb9&#039;<\/p>\n<p>-f \u8868\u793a\u5b9e\u65f6<br \/>\n-n \u8868\u793a \u6307\u5b9a\u6700\u8fd1\u591a\u5c11\u884c<\/p>\n<p># \u8fd8\u53ef\u4ee5\u540c\u65f6\u67e5\u770b\u591a\u4e2a\u65e5\u5fd7\u6587\u4ef6<br \/>\ntail -f  *.log<\/p>\n<p>\u7edf\u8ba1\u67d0\u9519\u8bef\u51fa\u73b0\u6b21\u6570<br \/>\n\u6bd4\u5982\u7edf\u8ba1\u7a7a\u6307\u9488<\/p>\n<p>grep &#034;NullPointerException&#034; app.log | wc -l<\/p>\n<p>\u7ebf\u4e0a\u6392\u67e5\u95ee\u9898\u65f6\u6700\u5e38\u7528\u547d\u4ee4\u3002<\/p>\n<hr \/>\n<h4>3. \u7f16\u8f91\u6587\u4ef6<\/h4>\n<p>\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u662f\u975e\u5e38\u5e38\u89c1\u7684\u64cd\u4f5c\u3002<\/p>\n<p>1\ufe0f\u20e3 vi&#xff08;\u51e0\u4e4e\u6240\u6709 Linux \u670d\u52a1\u5668\u90fd\u81ea\u5e26&#xff09;<\/p>\n<p>vi file.txt<br \/>\nvim file.txt<\/p>\n<p>\u8fdb\u5165\u7f16\u8f91\u540e&#xff1a;<\/p>\n<ul>\n<li>i \u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f<\/li>\n<li>Esc \u9000\u51fa\u7f16\u8f91<\/li>\n<li>:wq \u4fdd\u5b58\u9000\u51fa<\/li>\n<li>:q! \u5f3a\u5236\u9000\u51fa<\/li>\n<\/ul>\n<hr \/>\n<p>2\ufe0f\u20e3 vim&#xff08;\u589e\u5f3a\u7248 vi&#xff0c;\u652f\u6301\u8bed\u6cd5\u9ad8\u4eae\u548c\u66f4\u5f3a\u5927\u7684\u7f16\u8f91\u529f\u80fd&#xff0c;\u64cd\u4f5c\u548c vi \u4e00\u6837&#xff09;<\/p>\n<p>vim file.txt<\/p>\n<hr \/>\n<p>3\ufe0f\u20e3 nano&#xff08;\u65b0\u624b\u53cb\u597d&#xff0c;\u64cd\u4f5c\u7b80\u5355&#xff1a;\u5e95\u90e8\u76f4\u63a5\u663e\u793a\u5feb\u6377\u952e\u63d0\u793a&#xff09;<\/p>\n<p>nano file.txt<\/p>\n<p>\u5e38\u7528\u5feb\u6377\u952e&#xff1a;<\/p>\n<ul>\n<li>Ctrl &#043; O  \u4fdd\u5b58<\/li>\n<li>Ctrl &#043; X  \u9000\u51fa<\/li>\n<li>Ctrl &#043; K \u526a\u5207\u4e00\u884c<\/li>\n<li>Ctrl &#043; U \u7c98\u8d34<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e09\u3001\u8fdb\u7a0b\u7ba1\u7406<\/h3>\n<p>\u670d\u52a1\u5668\u6392\u67e5\u95ee\u9898\u5e38\u7528\u3002<\/p>\n<h4>1. \u67e5\u770b\u8fdb\u7a0b<\/h4>\n<p>ps -ef | grep java<\/p>\n<hr \/>\n<h4>2. \u67e5\u770b\u7aef\u53e3\u5360\u7528<\/h4>\n<p>lsof -i:8080<br \/>\nnetstat -tunlp | grep 8080<\/p>\n<p>\u6216&#xff1a;<\/p>\n<p>ss -tunlp | grep 8080<\/p>\n<hr \/>\n<h4>3. \u6740\u6b7b\u8fdb\u7a0b<\/h4>\n<p>kill -9 \u8fdb\u7a0b\u53f7<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>kill -9 12345<\/p>\n<hr \/>\n<h4>4. \u5b9e\u65f6\u67e5\u770b\u8d44\u6e90<\/h4>\n<p>top<\/p>\n<p>\u66f4\u53cb\u597d\u7684\u7248\u672c&#xff1a;<\/p>\n<p>htop<\/p>\n<hr \/>\n<h3>\u56db\u3001\u6743\u9650\u7ba1\u7406<\/h3>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d&#xff0c;\u4e00\u5207\u7686\u6587\u4ef6&#xff08;Everything is a file&#xff09;&#xff0c;\u56e0\u6b64\u6743\u9650\u7ba1\u7406\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<h4>1. \u67e5\u770b\u6743\u9650<\/h4>\n<p>ls -l<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>-rwxr-xr-x<\/p>\n<p>\u89e3\u91ca&#xff1a;<\/p>\n<ul>\n<li>\u7b2c\u4e00\u4f4d&#xff1a;\u6587\u4ef6\u7c7b\u578b<\/li>\n<li>rwx&#xff1a;\u62e5\u6709\u8005\u6743\u9650<\/li>\n<li>r-x&#xff1a;\u7ec4\u6743\u9650<\/li>\n<li>r-x&#xff1a;\u5176\u4ed6\u7528\u6237\u6743\u9650<\/li>\n<\/ul>\n<hr \/>\n<h4>2. \u4fee\u6539\u6743\u9650<\/h4>\n<p>chmod 755 file.sh<br \/>\nchmod &#043;x file.sh<\/p>\n<hr \/>\n<h4>3. \u4fee\u6539\u6240\u5c5e\u7528\u6237<\/h4>\n<p>\u683c\u5f0f&#xff1a;chown \u7528\u6237\u540d:\u7528\u6237\u7ec4 \u6587\u4ef6\u540d<\/p>\n<p>\u6bd4\u5982 \u628a file.txt \u7684\u62e5\u6709\u8005\u6539\u4e3a root \u7528\u6237&#xff0c;\u540c\u65f6\u628a\u6240\u5c5e\u7ec4\u6539\u4e3a root \u7ec4<\/p>\n<p>chown root:root file.txt<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u538b\u7f29\u4e0e\u89e3\u538b<\/h3>\n<h4>1. tar \u547d\u4ee4<\/h4>\n<p>\u5c06 test\/ \u76ee\u5f55\u6253\u5305\u5e76\u538b\u7f29\u4e3a test.tar.gz&#xff1a;<\/p>\n<p>tar -czvf test.tar.gz test\/<\/p>\n<p>\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>-c create&#xff0c;\u521b\u5efa\u538b\u7f29\u5305<\/li>\n<li>-z \u4f7f\u7528 gzip \u538b\u7f29&#xff08;\u751f\u6210 .gz \u6587\u4ef6&#xff09;<\/li>\n<li>-v \u663e\u793a\u8be6\u7ec6\u8fc7\u7a0b&#xff08;verbose&#xff09;<\/li>\n<li>-f \u6307\u5b9a\u538b\u7f29\u5305\u6587\u4ef6\u540d<\/li>\n<\/ul>\n<p>\u5c06 test.tar.gz \u89e3\u538b\u5230\u5f53\u524d\u76ee\u5f55&#xff1a;<\/p>\n<p>tar -xzvf test.tar.gz<\/p>\n<p>\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>-x extract&#xff0c;\u89e3\u538b<\/li>\n<li>-z \u901a\u8fc7 gzip \u89e3\u538b<\/li>\n<li>-v \u663e\u793a\u8be6\u7ec6\u8fc7\u7a0b<\/li>\n<li>-f \u6307\u5b9a\u538b\u7f29\u5305\u6587\u4ef6\u540d<\/li>\n<\/ul>\n<hr \/>\n<h4>2. zip<\/h4>\n<p># \u9012\u5f52\u538b\u7f29<br \/>\nzip -r test.zip test\/<br \/>\n# \u89e3\u538b<br \/>\nunzip test.zip<\/p>\n<hr \/>\n<h3>\u516d\u3001\u78c1\u76d8\u4e0e\u5185\u5b58<\/h3>\n<h4>1. \u67e5\u770b\u78c1\u76d8\u7a7a\u95f4<\/h4>\n<p>df -h<\/p>\n<hr \/>\n<h4>2. \u67e5\u770b\u76ee\u5f55\u5927\u5c0f<\/h4>\n<p>du -sh *<br \/>\n# \u4e5f\u53ef\u4ee5\u6307\u5b9a\u6587\u4ef6\u5939<br \/>\ndu -sh \/logs\/rocketmqlogs\/*<\/p>\n<hr \/>\n<h4>3. \u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/h4>\n<p>free -m<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u7f51\u7edc\u76f8\u5173\u547d\u4ee4<\/h3>\n<h4>1. \u6d4b\u8bd5\u8fde\u901a\u6027<\/h4>\n<p>ping www.baidu.com<\/p>\n<hr \/>\n<h4>2. \u67e5\u770bIP\u5730\u5740<\/h4>\n<p>ip addr<\/p>\n<hr \/>\n<h4>3. \u6d4b\u8bd5\u7aef\u53e3\u662f\u5426\u901a<\/h4>\n<p>telnet 127.0.0.1 3306<\/p>\n<hr \/>\n<h4>4. \u4e0b\u8f7d\u6587\u4ef6<\/h4>\n<p>wget https:\/\/example.com\/file.zip<br \/>\ncurl -O https:\/\/example.com\/file.zip<\/p>\n<hr \/>\n<h3>\u516b\u3001\u670d\u52a1\u7ba1\u7406&#xff08;systemctl&#xff09;<\/h3>\n<p>\u5728\u5927\u591a\u6570\u57fa\u4e8e systemd \u7684 Linux \u53d1\u884c\u7248\u4e2d&#xff08;\u5982&#xff1a;CentOS\u3001 Ubuntu\u3001 Debian&#xff09;:<\/p>\n<p>systemctl start nginx<br \/>\nsystemctl stop nginx<br \/>\nsystemctl restart nginx<br \/>\nsystemctl status nginx<\/p>\n<p>\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8&#xff1a;<\/p>\n<p>systemctl enable nginx<\/p>\n<hr \/>\n<h3>\u4e5d\u3001\u5e38\u89c1\u670d\u52a1\u5668\u6392\u67e5\u601d\u8def<\/h3>\n<p>\u5f53\u670d\u52a1\u5668\u8bbf\u95ee\u5f02\u5e38\u65f6&#xff0c;\u4e00\u822c\u6392\u67e5\u6b65\u9aa4&#xff1a;<\/p>\n<li>\n<p>\u670d\u52a1\u662f\u5426\u8fd0\u884c&#xff1f;<\/p>\n<p>ps -ef | grep \u670d\u52a1\u540d<\/p>\n<\/li>\n<li>\n<p>\u7aef\u53e3\u662f\u5426\u76d1\u542c&#xff1f;<\/p>\n<p>netstat -tunlp<\/p>\n<\/li>\n<li>\n<p>\u9632\u706b\u5899\u662f\u5426\u653e\u884c&#xff1f;<\/p>\n<p>firewall-cmd &#8211;list-all<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u65e5\u5fd7&#xff1a;<\/p>\n<p>tail -f logs\/app.log<\/p>\n<\/li>\n<hr \/>\n<h3>\u5341\u3001\u5e38\u89c1\u786c\u76d8\u6392\u67e5\u601d\u8def<\/h3>\n<p>\u5148\u770b\u770b\u662f\u54ea\u4e2a\u6587\u4ef6\u5360\u7528\u8fc7\u5927\u3002<\/p>\n<p>\u8fd9\u884c\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u7cfb\u7edf\u4e2d\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u6700\u5927\u768420\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u3002du -ahx \/ \u8ba1\u7b97\u4ece\u6839\u76ee\u5f55\u5f00\u59cb\u7684\u6240\u6709\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u5927\u5c0f&#xff0c;sort -rh \u6309\u5927\u5c0f\u9006\u5e8f\u6392\u5e8f&#xff0c;head -n 20 \u53ea\u663e\u793a\u524d20\u9879\u3002<\/p>\n<p>sudo du -ahx \/ | sort -rh | head -n 20<\/p>\n<p>\u6839\u636e\u627e\u5230\u7684\u6587\u4ef6\u5927\u5c0f\u6392\u884c&#xff0c;\u9010\u4e00\u53bb\u6392\u67e5&#xff0c;<\/p>\n<p>\u5982\u679c\u662f\u6587\u4ef6&#xff0c;\u6bd4\u5982\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u90a3\u5c31&#xff1a;<\/p>\n<p>tail -f \/path\/app.log<\/p>\n<p>\u5982\u679c\u662f\u6587\u4ef6\u5939\u8fc7\u5927&#xff0c;\u5c31du\u4e00\u4e0b\u770b\u770b\u5177\u4f53\u662f\u54ea\u4e2a\u6587\u4ef6\u7684\u95ee\u9898<\/p>\n<p>\u4ee5\/root\/logs\/rocketmqlogs\u4e3a\u4f8b&#xff1a;<\/p>\n<p>du -sh \/root\/logs\/rocketmqlogs\/*<\/p>\n<hr \/>\n<h3>\u5341\u4e00\u3001\u670d\u52a1\u5668\u7cfb\u7edf\u4fe1\u606f<\/h3>\n<h4>1. \u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u53d1\u884c\u7248\u4fe1\u606f<\/h4>\n<p>cat \/etc\/os-release<\/p>\n<p>\u8f93\u51fa\u793a\u4f8b&#xff1a;<\/p>\n<p>NAME&#061;&#034;CentOS Linux&#034;<br \/>\nVERSION&#061;&#034;7 (Core)&#034;<\/p>\n<p>\u6216\u8005&#xff1a;<\/p>\n<p>lsb_release -a<\/p>\n<p>\u26a0\ufe0f \u8be5\u547d\u4ee4\u9700\u8981\u5b89\u88c5 lsb-release \u5305&#xff0c;\u67d0\u4e9b\u7cfb\u7edf\u9ed8\u8ba4\u672a\u5b89\u88c5\u3002<\/p>\n<p>\u5e38\u89c1\u670d\u52a1\u5668\u7cfb\u7edf\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>CentOS<\/li>\n<li>Ubuntu<\/li>\n<li>Debian<\/li>\n<\/ul>\n<hr \/>\n<h4>2. \u67e5\u770b\u5185\u6838\u7248\u672c<\/h4>\n<p>uname -r<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa&#xff1a;<\/p>\n<p>3.10.0-1160.el7.x86_64<\/p>\n<p>\u8bf4\u660e\u5f53\u524d Linux \u5185\u6838\u7248\u672c\u3002<\/p>\n<hr \/>\n<h4>3. \u67e5\u770b\u5b8c\u6574\u7cfb\u7edf\u4fe1\u606f<\/h4>\n<p>uname -a<\/p>\n<p>\u53ef\u67e5\u770b&#xff1a;<\/p>\n<ul>\n<li>\u4e3b\u673a\u540d<\/li>\n<li>\u5185\u6838\u7248\u672c<\/li>\n<li>\u7cfb\u7edf\u67b6\u6784<\/li>\n<li>\u7f16\u8bd1\u65f6\u95f4<\/li>\n<\/ul>\n<hr \/>\n<h4>4. \u67e5\u770b\u7cfb\u7edf\u67b6\u6784&#xff08;32\u4f4d \/ 64\u4f4d&#xff09;<\/h4>\n<p>arch<\/p>\n<p>\u6216\u8005&#xff1a;<\/p>\n<p>uname -m<\/p>\n<p>\u5e38\u89c1\u7ed3\u679c&#xff1a;<\/p>\n<ul>\n<li>x86_64 \u2192 64\u4f4d\u7cfb\u7edf<\/li>\n<li>i686 \u2192 32\u4f4d\u7cfb\u7edf<\/li>\n<\/ul>\n<hr \/>\n<h4>5. \u67e5\u770b\u7cfb\u7edf\u8fd0\u884c\u65f6\u95f4<\/h4>\n<p>uptime<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa&#xff1a;<\/p>\n<p>10:32:10 up 15 days,  3:12,  2 users,  load average: 0.00, 0.01, 0.05<\/p>\n<p>\u53ef\u67e5\u770b&#xff1a;<\/p>\n<ul>\n<li>\u5f53\u524d\u65f6\u95f4<\/li>\n<li>\u7cfb\u7edf\u5df2\u8fd0\u884c\u65f6\u95f4<\/li>\n<li>\u5f53\u524d\u5728\u7ebf\u7528\u6237\u6570<\/li>\n<li>\u7cfb\u7edf\u8d1f\u8f7d<\/li>\n<\/ul>\n<hr \/>\n<h3>\u5341\u4e8c\u3001\u7528\u6237\u4e0e\u8d26\u6237\u7ba1\u7406<\/h3>\n<h4>1. \u67e5\u770b\u5f53\u524d\u767b\u5f55\u7528\u6237<\/h4>\n<p>who<br \/>\n# \u6216\u8005<br \/>\nw<\/p>\n<hr \/>\n<h4>2. \u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7528\u6237<\/h4>\n<p>cat \/etc\/passwd<\/p>\n<p>\u53ea\u770b\u666e\u901a\u7528\u6237&#xff08;UID &gt;&#061; 1000&#xff09;&#xff1a;<\/p>\n<p>awk -F: &#039;$3&gt;&#061;1000 {print $1}&#039; \/etc\/passwd<\/p>\n<hr \/>\n<h4>3. \u521b\u5efa\u65b0\u7528\u6237<\/h4>\n<p>useradd -m -s \/bin\/bash deploy<br \/>\n# \u7b80\u6613\u5199\u6cd5&#xff1a;<br \/>\nuseradd deploy<\/p>\n<p>\u26a0\ufe0f \u4e0d\u6307\u5b9a -s \/bin\/bash \u65f6&#xff0c;\u90e8\u5206\u7cfb\u7edf\u9ed8\u8ba4 shell \u53ef\u80fd\u4e3a \/sbin\/nologin&#xff0c;\u4f1a\u5bfc\u81f4\u65e0\u6cd5\u767b\u5f55\u3002<\/p>\n<p>\u8fd9\u4e2a\u53ea\u662f\u521b\u5efa\u7528\u6237&#xff0c;\u6ca1\u8bbe\u7f6e\u5bc6\u7801\u7b49\u3002<\/p>\n<p>\u63a8\u8350\u521b\u5efa\u7528\u6237\u6807\u51c6\u6d41\u7a0b&#xff1a;<\/p>\n<p># \u521b\u5efa\u7528\u6237<br \/>\nuseradd -m -s \/bin\/bash deploy<\/p>\n<p># \u8bbe\u7f6e\u5bc6\u7801<br \/>\npasswd deploy<\/p>\n<p># \u52a0\u5165 sudo \u7ec4<br \/>\nusermod -aG sudo deploy<\/p>\n<p># \u6d4b\u8bd5<br \/>\nsu &#8211; deploy<br \/>\nsudo ls \/<\/p>\n<h4>4. \u8bbe\u7f6e\u6216\u4fee\u6539\u7528\u6237\u5bc6\u7801<\/h4>\n<p>passwd username<\/p>\n<p>\u4fee\u6539\u5f53\u524d\u7528\u6237\u5bc6\u7801&#xff1a;<\/p>\n<p>passwd<\/p>\n<hr \/>\n<h4>5. \u5220\u9664\u7528\u6237<\/h4>\n<p>\u53ea\u5220\u9664\u7528\u6237&#xff1a;<\/p>\n<p>userdel username<\/p>\n<p>\u5220\u9664\u7528\u6237 &#043; home \u76ee\u5f55&#xff1a;<\/p>\n<p>userdel -r username<\/p>\n<hr \/>\n<h4>6. \u5207\u6362\u7528\u6237<\/h4>\n<p>su &#8211; username<\/p>\n<p>\u5207\u6362 root&#xff1a;<\/p>\n<p>su &#8211;<\/p>\n<hr \/>\n<h4>7. \u7ed9\u7528\u6237 sudo \u6743\u9650<\/h4>\n<p>Ubuntu \u63a8\u8350&#xff1a;<\/p>\n<p>usermod -aG sudo username<\/p>\n<p>CentOS\u63a8\u8350&#xff1a;<\/p>\n<p>usermod -aG wheel username<\/p>\n<hr \/>\n<h4>8. \u67e5\u770b\u7528\u6237\u6240\u5c5e\u7ec4<\/h4>\n<p>groups username<\/p>\n<p>\u6743\u9650\u6392\u67e5\u795e\u5668&#xff1a;<\/p>\n<p>id username<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa&#xff1a;<\/p>\n<p>uid&#061;1001(deploy) gid&#061;1001(deploy) groups&#061;1001(deploy),27(sudo)<\/p>\n<p>\u8fd9\u4e2a\u5728 Docker\u3001FTP \u6743\u9650\u95ee\u9898\u6392\u67e5\u65f6\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<hr \/>\n<h4>9. \u7981\u6b62 root \u76f4\u63a5\u8fdc\u7a0b\u767b\u5f55<\/h4>\n<p>\u6709\u4e9b\u573a\u666f\u53ef\u80fd\u9700\u8981\u7981\u6b62root&#xff0c;<br \/>\n\u26a0\ufe0f \u4f46\u4e00\u5b9a\u8981\u5148\u786e\u8ba4\u666e\u901a\u7528\u6237\u80fd sudo&#xff0c;\u5426\u5219\u4f1a\u9501\u6b7b\u81ea\u5df1\u3002\u5efa\u8bae\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u521b\u5efa\u666e\u901a\u7528\u6237<\/li>\n<li>\u7ed9 sudo \u6743\u9650<\/li>\n<li>\u6d4b\u8bd5 sudo<\/li>\n<li>\u4fee\u6539 root \u5bc6\u7801<\/li>\n<li>\u7981\u6b62 root \u767b\u5f55<\/li>\n<p>\u7981\u6b62 root \u76f4\u63a5\u8fdc\u7a0b\u767b\u5f55\u6d41\u7a0b&#xff1a;<\/p>\n<p>vim \/etc\/ssh\/sshd_config<\/p>\n<p>\u627e\u5230&#xff1a;PermitRootLogin yes<br \/>\n\u6539\u4e3a&#xff1a;PermitRootLogin no<br \/>\n\u7136\u540e&#xff1a;<\/p>\n<p>systemctl restart sshd<br \/>\n# \u67d0\u4e9b Ubuntu \u7cfb\u7edf\u670d\u52a1\u4e5f\u53ef\u80fd\u540d\u4e3a ssh \u5219\u6267\u884c&#xff1a;<br \/>\nsystemctl restart ssh<\/p>\n<h4>10. \u9501\u5b9a\u7528\u6237<\/h4>\n<p>\u6709\u65f6\u5019\u4e0d\u5220\u9664\u7528\u6237&#xff0c;\u53ea\u662f\u7981\u7528&#xff1a;<\/p>\n<p>usermod -L username   # \u9501\u5b9a<br \/>\nusermod -U username   # \u89e3\u9501<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6574\u7406\u4e86\u4e00\u4e9b\u81ea\u5df1\u5e38\u7528\u7684 \u670d\u52a1\u5668\u547d\u4ee4\u6e05\u5355&#xff0c;\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001\u8fdb\u7a0b\u7ba1\u7406\u3001\u7f51\u7edc\u6392\u67e5\u3001\u6743\u9650\u63a7\u5236\u3001\u65e5\u5fd7\u5206\u6790\u7b49\u6838\u5fc3\u5185\u5bb9\u3002\u4e00\u3001\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c<br \/>\n1. \u67e5\u770b\u76ee\u5f55\u5185\u5bb9<br \/>\nls# \u67e5\u770b\u76ee\u5f55\u5185\u5bb9<br \/>\nls -l# \u8be6\u7ec6\u4fe1\u606f<br \/>\nls -lh# \u53cb\u597d\u663e\u793a\u6587\u4ef6\u5927\u5c0f<br \/>\nls -a# \u663e\u793a\u9690\u85cf\u6587\u4ef62. \u5207\u6362\u76ee\u5f55<br \/>\ncd \/home# \u5207\u6362\u5230\u6307\u5b9a\u76ee\u5f55<br \/>\ncd ..# \u8fd4\u56de\u4e0a\u4e00\u7ea7<br \/>\ncd ~# \u56de\u5230\u7528\u6237\u76ee\u5f553. \u521b\u5efa\u548c\u5220\u9664<br \/>\n\u521b\u5efa&#xff1a;<br \/>\nmkdir test           # \u521b\u5efa\u76ee\u5f55<br \/>\nmkdir -p<\/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":[58,43,44],"topic":[],"class_list":["post-77148","post","type-post","status-publish","format-standard","hentry","category-server","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 \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \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\/77148.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u6574\u7406\u4e86\u4e00\u4e9b\u81ea\u5df1\u5e38\u7528\u7684 \u670d\u52a1\u5668\u547d\u4ee4\u6e05\u5355&#xff0c;\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001\u8fdb\u7a0b\u7ba1\u7406\u3001\u7f51\u7edc\u6392\u67e5\u3001\u6743\u9650\u63a7\u5236\u3001\u65e5\u5fd7\u5206\u6790\u7b49\u6838\u5fc3\u5185\u5bb9\u3002\u4e00\u3001\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c 1. \u67e5\u770b\u76ee\u5f55\u5185\u5bb9 ls# \u67e5\u770b\u76ee\u5f55\u5185\u5bb9 ls -l# \u8be6\u7ec6\u4fe1\u606f ls -lh# \u53cb\u597d\u663e\u793a\u6587\u4ef6\u5927\u5c0f ls -a# \u663e\u793a\u9690\u85cf\u6587\u4ef62. \u5207\u6362\u76ee\u5f55 cd \/home# \u5207\u6362\u5230\u6307\u5b9a\u76ee\u5f55 cd ..# \u8fd4\u56de\u4e0a\u4e00\u7ea7 cd ~# \u56de\u5230\u7528\u6237\u76ee\u5f553. \u521b\u5efa\u548c\u5220\u9664 \u521b\u5efa&#xff1a; mkdir test      # \u521b\u5efa\u76ee\u5f55 mkdir -p\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/77148.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-23T17:17:22+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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77148.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/77148.html\",\"name\":\"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-23T17:17:22+00:00\",\"dateModified\":\"2026-02-23T17:17:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/77148.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/77148.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77148.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4\"}]},{\"@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 \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \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\/77148.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u672c\u6587\u6574\u7406\u4e86\u4e00\u4e9b\u81ea\u5df1\u5e38\u7528\u7684 \u670d\u52a1\u5668\u547d\u4ee4\u6e05\u5355&#xff0c;\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001\u8fdb\u7a0b\u7ba1\u7406\u3001\u7f51\u7edc\u6392\u67e5\u3001\u6743\u9650\u63a7\u5236\u3001\u65e5\u5fd7\u5206\u6790\u7b49\u6838\u5fc3\u5185\u5bb9\u3002\u4e00\u3001\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c 1. \u67e5\u770b\u76ee\u5f55\u5185\u5bb9 ls# \u67e5\u770b\u76ee\u5f55\u5185\u5bb9 ls -l# \u8be6\u7ec6\u4fe1\u606f ls -lh# \u53cb\u597d\u663e\u793a\u6587\u4ef6\u5927\u5c0f ls -a# \u663e\u793a\u9690\u85cf\u6587\u4ef62. \u5207\u6362\u76ee\u5f55 cd \/home# \u5207\u6362\u5230\u6307\u5b9a\u76ee\u5f55 cd ..# \u8fd4\u56de\u4e0a\u4e00\u7ea7 cd ~# \u56de\u5230\u7528\u6237\u76ee\u5f553. \u521b\u5efa\u548c\u5220\u9664 \u521b\u5efa&#xff1a; mkdir test      # \u521b\u5efa\u76ee\u5f55 mkdir -p","og_url":"https:\/\/www.wsisp.com\/helps\/77148.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-23T17:17:22+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/77148.html","url":"https:\/\/www.wsisp.com\/helps\/77148.html","name":"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-23T17:17:22+00:00","dateModified":"2026-02-23T17:17:22+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/77148.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/77148.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/77148.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u5e38\u7528\u670d\u52a1\u5668\u547d\u4ee4"}]},{"@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\/77148","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=77148"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/77148\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=77148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=77148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=77148"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=77148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}