{"id":102204,"date":"2026-09-08T11:12:27","date_gmt":"2026-09-08T03:12:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102204.html"},"modified":"2026-09-08T11:12:27","modified_gmt":"2026-09-08T03:12:27","slug":"linux-%e8%bf%90%e7%bb%b4%e5%85%a8%e5%a5%97%e5%91%bd%e4%bb%a4%e6%89%8b%e5%86%8c","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102204.html","title":{"rendered":"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c"},"content":{"rendered":"<p>\u9002\u7528&#xff1a;CentOS7\/8\u3001\u9e92\u9e9f Kylin V10\u3001Rocky\u3001Ubuntu&#xff1b;\u8986\u76d6\u65e5\u5e38\u8fd0\u7ef4\u3001\u6545\u969c\u6392\u67e5\u3001\u6587\u4ef6\u3001\u7f51\u7edc\u3001\u8fdb\u7a0b\u3001\u78c1\u76d8\u3001\u6743\u9650\u3001\u8f6f\u4ef6\u3001\u65e5\u5fd7\u3001\u538b\u7f29\u3001shell\u3001\u7cfb\u7edf\u72b6\u6001\u3002 \u6807\u6ce8\u5e38\u7528\u2605&#xff0c;\u751f\u4ea7\u9ad8\u9891\u91cd\u70b9\u6807\u8bb0\u3002<\/p>\n<h3>\u4e00\u3001\u57fa\u7840\u7cfb\u7edf\u4fe1\u606f<\/h3>\n<p>uname -a                # \u2605\u67e5\u770b\u5185\u6838\u3001\u7cfb\u7edf\u5168\u90e8\u4fe1\u606f<br \/>\nuname -r                # \u5185\u6838\u7248\u672c<br \/>\ncat \/etc\/os-release     # \u2605\u67e5\u770b\u53d1\u884c\u7248\u672c&#xff08;\u9e92\u9e9f\u3001CentOS&#xff09;<br \/>\nhostname                # \u4e3b\u673a\u540d<br \/>\nhostnamectl set-hostname app01  # \u4fee\u6539\u4e3b\u673a\u540d<br \/>\nuptime                  # \u2605\u7cfb\u7edf\u8fd0\u884c\u65f6\u95f4\u3001\u8d1f\u8f7d<br \/>\ndate                    # \u5f53\u524d\u65f6\u95f4<br \/>\ntimedatectl             # \u2605\u65f6\u533a\u65f6\u95f4\u72b6\u6001<br \/>\ntimedatectl set-timezone Asia\/Shanghai # \u8bbe\u7f6e\u4e0a\u6d77\u65f6\u533a<br \/>\nwhoami                  # \u5f53\u524d\u7528\u6237<br \/>\nwho                     # \u767b\u5f55\u7528\u6237<br \/>\nw                       # \u2605\u767b\u5f55\u7528\u6237&#043;\u8d1f\u8f7d<br \/>\nlast                    # \u767b\u5f55\u5386\u53f2<br \/>\nhistory                 # \u2605\u5386\u53f2\u547d\u4ee4<br \/>\nhistory -c              # \u6e05\u7a7a\u5f53\u524d\u4f1a\u8bdd\u5386\u53f2<\/p>\n<h3>\u4e8c\u3001\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c<\/h3>\n<p>pwd                     # \u2605\u663e\u793a\u5f53\u524d\u8def\u5f84<br \/>\nls                      # \u5217\u51fa\u6587\u4ef6<br \/>\nls -l                   # \u2605\u8be6\u7ec6\u5217\u8868<br \/>\nls -la                  # \u2605\u542b\u9690\u85cf\u6587\u4ef6<br \/>\nls -lh                  # \u2605\u4eba\u6027\u5316\u5927\u5c0f\u663e\u793a<br \/>\nls -lt                  # \u6309\u65f6\u95f4\u6392\u5e8f<br \/>\ncd \/data                # \u5207\u6362\u76ee\u5f55<br \/>\ncd ..                   # \u8fd4\u56de\u4e0a\u4e00\u7ea7<br \/>\ncd ~                    # \u56de\u5230\u5bb6\u76ee\u5f55<br \/>\ncd &#8211;                    # \u8fd4\u56de\u4e0a\u4e00\u6b21\u76ee\u5f55<\/p>\n<p>mkdir test              # \u521b\u5efa\u6587\u4ef6\u5939<br \/>\nmkdir -p \/data\/logs\/tomcat  # \u2605\u9012\u5f52\u521b\u5efa\u591a\u7ea7\u76ee\u5f55<\/p>\n<p>rm file.txt             # \u5220\u9664\u6587\u4ef6<br \/>\nrm -rf dir              # \u2605\u5f3a\u5236\u9012\u5f52\u5220\u9664&#xff08;\u9ad8\u5371&#xff01;\u8c28\u614e&#xff09;<\/p>\n<p>cp a.txt \/tmp\/          # \u590d\u5236\u6587\u4ef6<br \/>\ncp -r dir1 dir2         # \u590d\u5236\u76ee\u5f55<\/p>\n<p>mv old.txt new.txt      # \u2605\u79fb\u52a8\/\u91cd\u547d\u540d<\/p>\n<p>touch file.txt          # \u521b\u5efa\u7a7a\u6587\u4ef6<\/p>\n<p>find \/data -name &#034;*.log&#034;        # \u2605\u67e5\u627e\u6587\u4ef6<br \/>\nfind \/data -type f -size &#043;100M  # \u67e5\u627e\u5927\u4e8e100M\u6587\u4ef6<br \/>\nfind \/data -mtime -7            # 7\u5929\u5185\u4fee\u6539\u6587\u4ef6<\/p>\n<p>ln -s \/usr\/local\/tomcat9 \/tomcat # \u2605\u8f6f\u94fe\u63a5<br \/>\nln \u6e90 \u76ee\u6807                       # \u786c\u94fe\u63a5<\/p>\n<h3>\u4e09\u3001\u6587\u4ef6\u67e5\u770b\u7f16\u8f91<\/h3>\n<p>cat file.txt            # \u5168\u90e8\u8f93\u51fa<br \/>\nmore file.txt           # \u5206\u9875\u6d4f\u89c8<br \/>\nless file.txt           # \u2605\u63a8\u8350\u5206\u9875\u67e5\u770b&#xff0c;q\u9000\u51fa<br \/>\nhead -n20 file.txt      # \u2605\u770b\u524d20\u884c<br \/>\ntail -n20 file.txt      # \u2605\u770b\u672b\u5c3e20\u884c<br \/>\ntail -f catalina.out    # \u2605\u5b9e\u65f6\u8ddf\u8e2a\u65e5\u5fd7<br \/>\ntail -F catalina.out    # \u2605\u65e5\u5fd7\u8f6e\u8f6c\u4e5f\u53ef\u8ddf\u8e2a<\/p>\n<p>grep &#034;error&#034; catalina.out           # \u2605\u8fc7\u6ee4\u5173\u952e\u5b57<br \/>\ngrep -i &#034;error&#034; catalina.out        # \u5ffd\u7565\u5927\u5c0f\u5199<br \/>\ngrep -v &#034;info&#034; catalina.out         # \u6392\u9664\u5339\u914d\u884c<br \/>\ngrep -rn &#034;Exception&#034; \/data\/tomcat   # \u2605\u9012\u5f52\u76ee\u5f55\u641c\u7d22\u5173\u952e\u5b57<\/p>\n<p>vi \/etc\/profile         # vi\u7f16\u8f91\u5668<br \/>\n# vi\u5feb\u6377\u952e<br \/>\ni           # \u7f16\u8f91<br \/>\nesc         # \u9000\u51fa\u7f16\u8f91<br \/>\n:w          # \u4fdd\u5b58<br \/>\n:q          # \u9000\u51fa<br \/>\n:wq         # \u2605\u4fdd\u5b58\u9000\u51fa<br \/>\n:q!         # \u2605\u5f3a\u5236\u4e0d\u4fdd\u5b58\u9000\u51fa<br \/>\ndd          # \u5220\u9664\u4e00\u884c<br \/>\nyy          # \u590d\u5236\u4e00\u884c<br \/>\np           # \u7c98\u8d34<br \/>\n\/\u5173\u952e\u8bcd      # \u5411\u4e0b\u641c\u7d22<br \/>\n?\u5173\u952e\u8bcd      # \u5411\u4e0a\u641c\u7d22<br \/>\nset nu      # \u663e\u793a\u884c\u53f7<\/p>\n<h3>\u56db\u3001\u6743\u9650 &amp; \u7528\u6237\u7ba1\u7406<\/h3>\n<p>id                      # \u67e5\u770b\u5f53\u524d\u7528\u6237uid gid<br \/>\nuseradd tomcat          # \u521b\u5efa\u7528\u6237<br \/>\nuserdel -r tomcat       # \u5220\u9664\u7528\u6237&#043;\u5bb6\u76ee\u5f55<br \/>\npasswd tomcat           # \u8bbe\u7f6e\u5bc6\u7801<\/p>\n<p>usermod -aG wheel tomcat # \u6dfb\u52a0\u5230sudo\u7ec4<\/p>\n<p>chmod 755 run.sh        # \u2605\u4fee\u6539\u6743\u9650<br \/>\nchmod &#043;x run.sh         # \u2605\u589e\u52a0\u6267\u884c\u6743\u9650<\/p>\n<p>chown tomcat:tomcat \/data\/tomcat9 -R # \u2605\u9012\u5f52\u4fee\u6539\u5c5e\u4e3b\u5c5e\u7ec4<\/p>\n<p>su &#8211; tomcat             # \u2605\u5207\u6362\u7528\u6237&#xff0c;\u52a0\u8f7d\u73af\u5883\u53d8\u91cf<br \/>\nsudo command            # \u7ba1\u7406\u5458\u6267\u884c<\/p>\n<p># \u6743\u9650\u6570\u5b57\u8bb0\u5fc6<br \/>\n# r&#061;4 w&#061;2 x&#061;1<br \/>\n# 755&#xff1a;rwxr-xr-x<br \/>\n# 644&#xff1a;rw-r&#8211;r&#8211;<\/p>\n<h3>\u4e94\u3001\u78c1\u76d8\u7a7a\u95f4<\/h3>\n<p>df -h                   # \u2605\u78c1\u76d8\u5206\u533a\u4f7f\u7528<br \/>\ndf -i                   # inode\u4f7f\u7528<br \/>\ndu -sh *                # \u2605\u5f53\u524d\u76ee\u5f55\u5404\u6587\u4ef6\u5927\u5c0f<br \/>\ndu -sh \/data            # \u76ee\u5f55\u603b\u5927\u5c0f<br \/>\ndu -sh \/data\/* | sort -hr # \u2605\u6309\u5927\u5c0f\u6392\u5e8f&#xff0c;\u627e\u5927\u6587\u4ef6<\/p>\n<p>lsblk                   # \u67e5\u770b\u5757\u8bbe\u5907<br \/>\nfdisk -l                # \u78c1\u76d8\u5206\u533a<br \/>\nmount \/dev\/sdb1 \/data   # \u6302\u8f7d<br \/>\numount \/data            # \u5378\u8f7d<br \/>\nblkid                   # \u83b7\u53d6UUID<br \/>\ncat \/etc\/fstab          # \u2605\u5f00\u673a\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6<\/p>\n<h3>\u516d\u3001\u8fdb\u7a0b\u3001\u5185\u5b58\u3001CPU<\/h3>\n<p>top                     # \u2605\u7cfb\u7edf\u8d44\u6e90\u76d1\u63a7<br \/>\n# top\u5feb\u6377\u952e<br \/>\nP \u6309CPU\u6392\u5e8f<br \/>\nM \u6309\u5185\u5b58\u6392\u5e8f<br \/>\nq \u9000\u51fa<\/p>\n<p>htop                    # \u589e\u5f3atop&#xff08;\u9700\u5b89\u88c5&#xff09;<br \/>\nfree -h                 # \u2605\u5185\u5b58\u3001swap<br \/>\nps -ef                  # \u2605\u67e5\u770b\u5168\u90e8\u8fdb\u7a0b<br \/>\nps aux                  # \u8fdb\u7a0b\u8be6\u7ec6<br \/>\nps -ef | grep tomcat    # \u2605\u8fc7\u6ee4\u8fdb\u7a0b<\/p>\n<p>pgrep -f tomcat         # \u83b7\u53d6\u8fdb\u7a0bPID<\/p>\n<p>kill 1234               # \u6b63\u5e38\u7ec8\u6b62\u8fdb\u7a0b<br \/>\nkill -9 1234            # \u2605\u5f3a\u5236\u6740\u8fdb\u7a0b&#xff08;\u5c3d\u91cf\u5c11\u7528&#xff09;<\/p>\n<p>nice \/ renice           # \u8c03\u6574\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/p>\n<p># \u67e5\u770b\u7ebf\u7a0b<br \/>\nps -T -p PID<br \/>\ntop -Hp PID<\/p>\n<h3>\u4e03\u3001\u7f51\u7edc\u547d\u4ee4<\/h3>\n<p>ip addr                 # \u2605\u67e5\u770b\u7f51\u5361IP<br \/>\nifconfig                # \u8001\u5de5\u5177<br \/>\nip route                # \u8def\u7531\u8868<br \/>\nroute -n<\/p>\n<p>ping 192.168.1.100      # ping\u6d4b\u8bd5\u8fde\u901a<br \/>\ntelnet 192.168.1.100 8080 # \u2605\u7aef\u53e3\u8fde\u901a\u6d4b\u8bd5<br \/>\ncurl -v http:\/\/127.0.0.1:8080 # \u2605\u8bbf\u95eehttp\u670d\u52a1<br \/>\nwget url                # \u4e0b\u8f7d\u6587\u4ef6<\/p>\n<p>netstat -tulnp          # \u2605\u67e5\u770b\u76d1\u542c\u7aef\u53e3&#xff08;\u9700net-tools&#xff09;<br \/>\nss -tulnp               # \u2605\u66ff\u4ee3netstat&#xff0c;\u6027\u80fd\u66f4\u597d<br \/>\nss -s                   # \u7edf\u8ba1\u8fde\u63a5\u6570<\/p>\n<p># \u9632\u706b\u5899 firewalld(CentOS\/\u9e92\u9e9fV10)<br \/>\nfirewall-cmd &#8211;list-all<br \/>\nfirewall-cmd &#8211;add-port&#061;8080\/tcp &#8211;permanent<br \/>\nfirewall-cmd &#8211;reload<br \/>\nsystemctl status firewalld<br \/>\nsystemctl stop firewalld<\/p>\n<p># ubuntu ufw<br \/>\nufw status<br \/>\nufw allow 8080<br \/>\nufw reload<\/p>\n<p># DNS<br \/>\ncat \/etc\/resolv.conf<br \/>\nnslookup baidu.com<br \/>\ndig baidu.com<\/p>\n<p># \u6293\u5305<br \/>\ntcpdump -i any port 8080 -w test.pcap<br \/>\ntcpdump -i eth0 host 192.168.1.10<\/p>\n<h3>\u516b\u3001\u670d\u52a1\u7ba1\u7406 systemd&#xff08;CentOS7&#043;\/ \u9e92\u9e9f V10&#xff09;<\/h3>\n<p>systemctl list-unit-files &#8211;type&#061;service # \u5217\u51fa\u6240\u6709\u670d\u52a1<\/p>\n<p>systemctl start tomcat      # \u2605\u542f\u52a8<br \/>\nsystemctl stop tomcat       # \u2605\u505c\u6b62<br \/>\nsystemctl restart tomcat    # \u2605\u91cd\u542f<br \/>\nsystemctl status tomcat     # \u2605\u67e5\u770b\u72b6\u6001<br \/>\nsystemctl enable tomcat     # \u2605\u5f00\u673a\u81ea\u542f<br \/>\nsystemctl disable tomcat    # \u53d6\u6d88\u5f00\u673a\u81ea\u542f<br \/>\nsystemctl daemon-reload     # \u2605\u4fee\u6539service\u540e\u91cd\u8f7d<\/p>\n<p>journalctl -u tomcat -f     # \u2605\u67e5\u770bsystemd\u670d\u52a1\u65e5\u5fd7\u5b9e\u65f6<br \/>\njournalctl -u tomcat &#8211;since &#034;2026-09-07 10:00:00&#034; # \u6307\u5b9a\u65f6\u95f4\u65e5\u5fd7<\/p>\n<h3>\u4e5d\u3001\u8f6f\u4ef6\u5305\u7ba1\u7406<\/h3>\n<h4>YUM&#xff08;CentOS \/ Kylin V10&#xff09;<\/h4>\n<p>yum list installed          # \u5df2\u5b89\u88c5\u5305<br \/>\nyum search xxx<br \/>\nyum install -y xxx          # \u2605\u5b89\u88c5<br \/>\nyum remove -y xxx           # \u5378\u8f7d<br \/>\nyum update -y               # \u66f4\u65b0<br \/>\nyum clean all                # \u6e05\u7406\u7f13\u5b58<\/p>\n<p>yum install -y net-tools lsof wget vim telnet tcpdump<\/p>\n<h4>APT&#xff08;Ubuntu&#xff09;<\/h4>\n<p>apt update<br \/>\napt install -y xxx<br \/>\napt remove xxx<br \/>\napt list &#8211;installed<\/p>\n<h4>RPM&#xff08;\u672c\u5730\u5305&#xff09;<\/h4>\n<p>rpm -ivh xxx.rpm            # \u5b89\u88c5rpm\u5305<br \/>\nrpm -qa | grep java         # \u67e5\u8be2\u5df2\u5b89\u88c5<br \/>\nrpm -e xxx                  # \u5378\u8f7d<\/p>\n<h3>\u5341\u3001\u538b\u7f29\u89e3\u538b<\/h3>\n<p># tar.gz \u6700\u5e38\u7528<br \/>\ntar -zcvf app.tar.gz \/data\/app  # \u2605\u538b\u7f29<br \/>\ntar -zxvf app.tar.gz -C \/tmp    # \u2605\u89e3\u538b\u5230\u6307\u5b9a\u76ee\u5f55<\/p>\n<p># tar.bz2<br \/>\ntar -jcvf xxx.tar.bz2 dir<br \/>\ntar -jxvf xxx.tar.bz2<\/p>\n<p># zip\/unzip<br \/>\nzip -r app.zip \/data\/app<br \/>\nunzip app.zip -d \/tmp<\/p>\n<p>gzip file<br \/>\ngunzip file.gz<\/p>\n<h3>\u5341\u4e00\u3001\u6587\u672c\u5904\u7406&#xff08;sed awk sort cut&#xff09;<\/h3>\n<p>cut -d: -f1 \/etc\/passwd     # \u6309:\u5206\u5272\u53d6\u7b2c1\u5217<br \/>\nsort file.txt               # \u6392\u5e8f<br \/>\nsort -hr                    # \u4eba\u7c7b\u6570\u5b57\u5927\u5c0f\u6392\u5e8f<br \/>\nuniq -c                     # \u53bb\u91cd\u7edf\u8ba1\u884c\u6570<\/p>\n<p>sed -i &#039;s\/old\/new\/g&#039; a.txt  # \u2605sed\u66ff\u6362\u6587\u4ef6\u5185\u5bb9<br \/>\nsed -i &#039;\/^#\/d&#039; file.conf    # \u5220\u9664#\u5f00\u5934\u884c<\/p>\n<p>awk &#039;{print $1,$3}&#039; test.txt # \u2605awk\u6253\u5370\u7b2c1\u30013\u5217<br \/>\nawk &#039;\/error\/{print}&#039; log.txt # \u5339\u914d\u884c\u8f93\u51fa<\/p>\n<h3>\u5341\u4e8c\u3001\u5b9a\u65f6\u4efb\u52a1 cron<\/h3>\n<p>crontab -e                  # \u2605\u7f16\u8f91\u5b9a\u65f6\u4efb\u52a1<br \/>\ncrontab -l                  # \u2605\u67e5\u770b\u5b9a\u65f6\u4efb\u52a1<br \/>\ncrontab -r                  # \u5220\u9664\u5b9a\u65f6\u4efb\u52a1<\/p>\n<p># cron\u683c\u5f0f \u5206 \u65f6 \u65e5 \u6708 \u5468<br \/>\n# 0 2 * * * \/bin\/sh \/data\/backup.sh &gt;&gt;\/data\/backup.log 2&gt;&amp;1<br \/>\n# \u6bcf\u5929\u51cc\u66682\u70b9\u6267\u884c\u811a\u672c<\/p>\n<p>systemctl status crond      # centos<br \/>\nsystemctl status cron       # ubuntu<\/p>\n<h3>\u5341\u4e09\u3001\u7cfb\u7edf\u8c03\u8bd5\u6545\u969c\u6392\u67e5<\/h3>\n<p>lsof -i :8080               # \u2605\u67e5\u770b\u54ea\u4e2a\u8fdb\u7a0b\u5360\u75288080\u7aef\u53e3<br \/>\nlsof | grep deleted         # \u2605\u67e5\u627e\u5df2\u5220\u9664\u672a\u91ca\u653e\u6587\u4ef6&#xff08;\u78c1\u76d8\u4e0d\u91ca\u653e&#xff09;<\/p>\n<p>vmstat 1                    # \u2605\u7cfb\u7edf\u72b6\u6001\u6bcf\u79d2\u8f93\u51fa<br \/>\niostat -x 1                 # \u2605\u78c1\u76d8IO\u76d1\u63a7<br \/>\nsar -n DEV 1                # \u2605\u7f51\u7edc\u6d41\u91cf\u76d1\u63a7<\/p>\n<p>dmesg                       # \u2605\u5185\u6838\u65e5\u5fd7&#xff0c;\u786c\u4ef6\u3001OOM\u62a5\u9519<br \/>\ndmesg | grep -i oom<\/p>\n<p>cat \/var\/log\/messages       # \u2605\u7cfb\u7edf\u65e5\u5fd7 centos\/\u9e92\u9e9f<br \/>\ncat \/var\/log\/syslog         # ubuntu<\/p>\n<p># OOM\u67e5\u770b<br \/>\ngrep -i oom-killer \/var\/log\/messages<\/p>\n<h3>\u5341\u56db\u3001\u8fdc\u7a0b\u4f20\u8f93<\/h3>\n<p>ssh root&#064;192.168.1.100     # ssh\u767b\u5f55<\/p>\n<p>scp \/data\/file.tar.gz root&#064;192.168.1.100:\/tmp  # \u2605\u672c\u5730\u4f20\u5230\u8fdc\u7a0b<br \/>\nscp root&#064;192.168.1.100:\/tmp\/file.tar.gz .\/     # \u8fdc\u7a0b\u4e0b\u8f7d\u5230\u672c\u5730<\/p>\n<p># rsync\u589e\u91cf\u540c\u6b65&#xff08;\u751f\u4ea7\u5907\u4efd&#xff09;<br \/>\nrsync -avz \/data\/ root&#064;192.168.1.100:\/backup\/<\/p>\n<h3>\u5341\u4e94\u3001\u73af\u5883\u53d8\u91cf<\/h3>\n<p>env                     # \u67e5\u770b\u5168\u90e8\u73af\u5883\u53d8\u91cf<br \/>\necho $JAVA_HOME         # \u6253\u5370\u53d8\u91cf<\/p>\n<p># \u5168\u5c40\u73af\u5883\u53d8\u91cf<br \/>\n\/etc\/profile            # \u6240\u6709\u7528\u6237\u767b\u5f55\u52a0\u8f7d<br \/>\n\/etc\/bashrc             # shell\u6253\u5f00\u52a0\u8f7d<br \/>\n~\/.bash_profile         # \u5f53\u524d\u7528\u6237<br \/>\n~\/.bashrc               # \u5f53\u524d\u7528\u6237shell<\/p>\n<p>source \/etc\/profile     # \u2605\u751f\u6548\u914d\u7f6e<br \/>\nexport JAVA_HOME&#061;\/xxx   # \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<h3>\u5341\u516d\u3001shell \u811a\u672c\u5e38\u7528\u5185\u7f6e<\/h3>\n<p>$0      #\u811a\u672c\u540d<br \/>\n$1 $2   #\u7b2c1\u30012\u4f20\u5165\u53c2\u6570<br \/>\n$#      #\u53c2\u6570\u4e2a\u6570<br \/>\n$?      # \u2605\u4e0a\u4e00\u6761\u547d\u4ee4\u8fd4\u56de\u503c&#xff0c;0\u6210\u529f\u975e0\u5931\u8d25<\/p>\n<p>&amp;&amp;      # \u524d\u9762\u6210\u529f\u624d\u6267\u884c\u540e\u9762<br \/>\n||      # \u524d\u9762\u5931\u8d25\u6267\u884c\u540e\u9762<br \/>\n;       # \u987a\u5e8f\u6267\u884c<\/p>\n<p># \u5224\u65ad\u793a\u4f8b<br \/>\nif [ $? -eq 0 ];then echo ok;fi<\/p>\n<h3>\u5341\u4e03\u3001\u5feb\u6377\u5b9e\u7528\u5c0f\u6280\u5de7<\/h3>\n<p>!123            # \u6267\u884chistory\u7f16\u53f7123\u547d\u4ee4<br \/>\n!!              # \u91cd\u590d\u4e0a\u4e00\u6761\u547d\u4ee4<br \/>\nctrl &#043; c        # \u7ec8\u6b62\u5f53\u524d\u8fd0\u884c\u7a0b\u5e8f<br \/>\nctrl &#043; z        # \u6302\u8d77\u7a0b\u5e8f\u5230\u540e\u53f0<br \/>\njobs            # \u540e\u53f0\u4efb\u52a1<br \/>\nbg %1           # \u540e\u53f0\u8fd0\u884c<br \/>\nfg %1           # \u5207\u56de\u524d\u53f0<\/p>\n<p>&gt; log.txt       # \u2605\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9&#xff08;\u4e0d\u8981rm&#xff0c;\u6587\u4ef6\u88ab\u5360\u7528\u65f6rm\u4e0d\u91ca\u653e\u7a7a\u95f4&#xff09;<\/p>\n<h3>\u5341\u516b\u3001\u751f\u4ea7\u6545\u969c\u6392\u67e5\u901f\u67e5\u6e05\u5355&#xff08;\u547d\u4ee4\u7ec4\u5408&#xff09;<\/h3>\n<li>\u78c1\u76d8\u6ee1<\/li>\n<p>df -h                    # \u67e5\u770b\u5404\u4e2a\u78c1\u76d8\u5206\u533a\u4f7f\u7528\u7387\u3001\u6302\u8f7d\u70b9&#xff0c;-h\u4eba\u6027\u5316\u663e\u793a\u5355\u4f4dGB\/MB<br \/>\ndu -sh \/* | sort -hr     # \u7edf\u8ba1\u6839\u76ee\u5f55\u4e0b\u6240\u6709\u76ee\u5f55\u603b\u5927\u5c0f&#xff0c;sort -hr\u6309\u6587\u4ef6\u5927\u5c0f\u4ece\u5927\u5230\u5c0f\u6392\u5e8f&#xff0c;\u5feb\u901f\u5b9a\u4f4d\u5927\u76ee\u5f55<br \/>\nlsof | grep deleted      # \u67e5\u627e\u5df2\u7ecf\u88abrm\u5220\u9664&#xff0c;\u4f46\u8fdb\u7a0b\u8fd8\u6301\u6709\u53e5\u67c4\u672a\u91ca\u653e\u7684\u6587\u4ef6&#xff1b;\u6587\u4ef6\u5220\u9664\u7a7a\u95f4\u4e0d\u91ca\u653e\u5fc5\u67e5<\/p>\n<li>\u7aef\u53e3\u5360\u7528<\/li>\n<p>ss -tulnp |grep 8080     # ss&#xff1a;\u65b0\u4e00\u4ee3\u7f51\u7edc\u5de5\u5177&#xff1b;-t tcp&#xff0c;-u udp&#xff0c;-l\u76d1\u542c\u7aef\u53e3&#xff0c;-n\u6570\u5b57\u4e0d\u89e3\u6790\u4e3b\u673a\u540d&#xff0c;-p\u663e\u793a\u8fdb\u7a0bPID&#xff1b;\u8fc7\u6ee48080&#xff0c;\u67e5\u54ea\u4e2a\u8fdb\u7a0b\u5728\u76d1\u542c\u8be5\u7aef\u53e3<br \/>\nlsof -i :8080            # lsof(list open files)&#xff0c;-i\u6307\u5b9a\u7f51\u7edc&#xff1b;\u67e5\u8be2\u5360\u75288080\u7aef\u53e3\u7684\u8fdb\u7a0bPID\u3001\u7528\u6237<\/p>\n<li>\u8fdb\u7a0b CPU \u9ad8<\/li>\n<p>top                      # \u7cfb\u7edf\u5b9e\u65f6\u76d1\u63a7\u9762\u677f&#xff0c;\u67e5\u770b\u6574\u4f53CPU\u3001\u5185\u5b58&#xff0c;\u6309P\u53ef\u6309CPU\u4f7f\u7528\u7387\u6392\u5e8f&#xff0c;M\u6309\u5185\u5b58\u6392\u5e8f<br \/>\nps -efH                  # -e\u5168\u90e8\u8fdb\u7a0b&#xff0c;-f\u5b8c\u6574\u683c\u5f0f&#xff0c;-H\u663e\u793a\u8fdb\u7a0b\u7236\u5b50\u6811\u5173\u7cfb&#xff1b;\u770b\u8fdb\u7a0b\u7236\u5b50\u5173\u7cfb&#xff0c;\u5b9a\u4f4d\u4e1a\u52a1\u8fdb\u7a0bPID<br \/>\ntop -Hp PID              # -H\u663e\u793a\u7ebf\u7a0b&#xff0c;-p\u6307\u5b9aPID&#xff1b;\u67e5\u770b\u8be5\u8fdb\u7a0b\u5185\u90e8\u5404\u4e2a\u7ebf\u7a0bCPU\u5360\u7528&#xff0c;\u5b9a\u4f4dJava\u7b49\u7a0b\u5e8f\u9ad8CPU\u7ebf\u7a0b<\/p>\n<li>\u5185\u5b58\u5f02\u5e38<\/li>\n<p>free -h                  # \u67e5\u770b\u603b\u5185\u5b58\u3001\u5df2\u7528\u3001\u7a7a\u95f2\u3001\u7f13\u5b58buffer\/cache\u3001swap\u4ea4\u6362\u5206\u533a\u4f7f\u7528\u60c5\u51b5<br \/>\nvmstat 1                 # \u865a\u62df\u5185\u5b58\u7edf\u8ba1&#xff0c;\u6bcf\u79d2\u5237\u65b01\u6b21&#xff1b;\u89c2\u5bdfsi(\u6362\u5165)\u3001so(\u6362\u51fa)&#xff0c;\u5224\u65ad\u662f\u5426\u5185\u5b58\u4e0d\u8db3\u53d1\u751fswap\u4ea4\u6362<br \/>\ndmesg |grep -i oom       # dmesg\u8bfb\u53d6\u5185\u6838\u73af\u5f62\u65e5\u5fd7&#xff1b;\u8fc7\u6ee4OOM Killer\u65e5\u5fd7&#xff0c;OOM\u5373\u5185\u5b58\u6ea2\u51fa&#xff0c;\u5185\u6838\u6740\u6389\u8fdb\u7a0b\u65f6\u4f1a\u6253\u5370\u8bb0\u5f55<\/p>\n<li>\u65e5\u5fd7\u62a5\u9519<\/li>\n<p>tail -f xxx.log          # -f\u5b9e\u65f6\u8ddf\u8e2a\u65e5\u5fd7\u6587\u4ef6\u672b\u5c3e\u8f93\u51fa&#xff1b;\u52a8\u6001\u770b\u5e94\u7528\u6eda\u52a8\u65e5\u5fd7&#xff0c;\u4e2d\u65ad\u6309Ctrl&#043;C<br \/>\ngrep -i error xxx.log    # -i\u5ffd\u7565\u5927\u5c0f\u5199&#xff1b;\u5728\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7b5b\u9009\u6240\u6709\u5305\u542berror\u7684\u62a5\u9519\u884c<br \/>\njournalctl -u \u670d\u52a1\u540d -f  # -u\u6307\u5b9asystemd\u670d\u52a1\u5355\u5143&#xff0c;-f\u5b9e\u65f6\u8ddf\u8e2a&#xff1b;\u67e5\u770bsystemd\u6258\u7ba1\u670d\u52a1\u7684\u7cfb\u7edf\u65e5\u5fd7&#xff08;\u5982tomcat.service&#xff09;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9002\u7528&#xff1a;CentOS7\/8\u3001\u9e92\u9e9f Kylin V10\u3001Rocky\u3001Ubuntu&#xff1b;\u8986\u76d6\u65e5\u5e38\u8fd0\u7ef4\u3001\u6545\u969c\u6392\u67e5\u3001\u6587\u4ef6\u3001\u7f51\u7edc\u3001\u8fdb\u7a0b\u3001\u78c1\u76d8\u3001\u6743\u9650\u3001\u8f6f\u4ef6\u3001\u65e5\u5fd7\u3001\u538b\u7f29\u3001shell\u3001\u7cfb\u7edf\u72b6\u6001\u3002 \u6807\u6ce8\u5e38\u7528\u2605&#xff0c;\u751f\u4ea7\u9ad8\u9891\u91cd\u70b9\u6807\u8bb0\u3002\u4e00\u3001\u57fa\u7840\u7cfb\u7edf\u4fe1\u606funame -a                # \u2605\u67e5\u770b\u5185\u6838\u3001\u7cfb\u7edf\u5168\u90e8\u4fe1\u606f<br \/>\nuname -r                # \u5185\u6838\u7248\u672c<br \/>\ncat \/etc\/os-release     # \u2605\u67e5\u770b\u53d1\u884c\u7248\u672c&amp;#xff0<\/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":[99,58,43],"topic":[],"class_list":["post-102204","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-linux","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \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\/102204.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9002\u7528&#xff1a;CentOS7\/8\u3001\u9e92\u9e9f Kylin V10\u3001Rocky\u3001Ubuntu&#xff1b;\u8986\u76d6\u65e5\u5e38\u8fd0\u7ef4\u3001\u6545\u969c\u6392\u67e5\u3001\u6587\u4ef6\u3001\u7f51\u7edc\u3001\u8fdb\u7a0b\u3001\u78c1\u76d8\u3001\u6743\u9650\u3001\u8f6f\u4ef6\u3001\u65e5\u5fd7\u3001\u538b\u7f29\u3001shell\u3001\u7cfb\u7edf\u72b6\u6001\u3002 \u6807\u6ce8\u5e38\u7528\u2605&#xff0c;\u751f\u4ea7\u9ad8\u9891\u91cd\u70b9\u6807\u8bb0\u3002\u4e00\u3001\u57fa\u7840\u7cfb\u7edf\u4fe1\u606funame -a        # \u2605\u67e5\u770b\u5185\u6838\u3001\u7cfb\u7edf\u5168\u90e8\u4fe1\u606f uname -r        # \u5185\u6838\u7248\u672c cat \/etc\/os-release   # \u2605\u67e5\u770b\u53d1\u884c\u7248\u672c&amp;#xff0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102204.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-08T03:12:27+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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102204.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102204.html\",\"name\":\"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-08T03:12:27+00:00\",\"dateModified\":\"2026-09-08T03:12:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102204.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102204.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102204.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c\"}]},{\"@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 \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \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\/102204.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9002\u7528&#xff1a;CentOS7\/8\u3001\u9e92\u9e9f Kylin V10\u3001Rocky\u3001Ubuntu&#xff1b;\u8986\u76d6\u65e5\u5e38\u8fd0\u7ef4\u3001\u6545\u969c\u6392\u67e5\u3001\u6587\u4ef6\u3001\u7f51\u7edc\u3001\u8fdb\u7a0b\u3001\u78c1\u76d8\u3001\u6743\u9650\u3001\u8f6f\u4ef6\u3001\u65e5\u5fd7\u3001\u538b\u7f29\u3001shell\u3001\u7cfb\u7edf\u72b6\u6001\u3002 \u6807\u6ce8\u5e38\u7528\u2605&#xff0c;\u751f\u4ea7\u9ad8\u9891\u91cd\u70b9\u6807\u8bb0\u3002\u4e00\u3001\u57fa\u7840\u7cfb\u7edf\u4fe1\u606funame -a        # \u2605\u67e5\u770b\u5185\u6838\u3001\u7cfb\u7edf\u5168\u90e8\u4fe1\u606f uname -r        # \u5185\u6838\u7248\u672c cat \/etc\/os-release   # \u2605\u67e5\u770b\u53d1\u884c\u7248\u672c&amp;#xff0","og_url":"https:\/\/www.wsisp.com\/helps\/102204.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-08T03:12:27+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102204.html","url":"https:\/\/www.wsisp.com\/helps\/102204.html","name":"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-08T03:12:27+00:00","dateModified":"2026-09-08T03:12:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102204.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102204.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102204.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u8fd0\u7ef4\u5168\u5957\u547d\u4ee4\u624b\u518c"}]},{"@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\/102204","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=102204"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102204\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102204"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}