centos系统中常用命令
Last updated
2023-01-28 10:38:21
{"value":"### \u65e5\u5fd7\n\ncentos\u7cfb\u7edf\u4e2d\u65e5\u5fd7\u6587\u4ef6\u5728\/var\/log\/ \u76ee\u5f55\u4e0b\n\n```\n[root@cdncloud ~]# cd \/var\/log\/ #\u901a\u8fc7cd \u8fdb\u5165\u8be5\u76ee\u5f55\n[root@cdncloud log]# ls #\u67e5\u770b\u8be5\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\n```\n\n```\nmessage #\u7cfb\u7edf\u542f\u52a8\u540e\u7684\u4fe1\u606f\u548c\u9519\u8bef\u65e5\u5fd7\nsecure #\u4e0e\u5b89\u5168\u76f8\u5173\u7684\u65e5\u5fd7\u4fe1\u606f\u00a0\nmaillog #\u4e0e\u90ae\u4ef6\u76f8\u5173\u7684\u65e5\u5fd7\u4fe1\u606f\u00a0\ncron #\u4e0e\u5b9a\u65f6\u4efb\u52a1\u76f8\u5173\u7684\u65e5\u5fd7\u4fe1\u606f\u00a0\nspooler #\u4e0eUUCP\u548cnews\u8bbe\u5907\u76f8\u5173\u7684\u65e5\u5fd7\u4fe1\u606f\u00a0\nboot.log #\u7cfb\u7edf\u542f\u52a8\u65f6\u7684\u65e5\u5fd7\ndmesg #\u5185\u6838\u7f13\u51b2\u4fe1\u606f\ndaemon.log #\u7cfb\u7edf\u540e\u53f0\u5b88\u62a4\u8fdb\u7a0b\u65e5\u5fd7\u4fe1\u606f\ndpkg.log #\u5b89\u88c5\u6216dpkg\u547d\u4ee4\u6e05\u9664\u8f6f\u4ef6\u5305\u7684\u65e5\u5fd7\nuser.log #\u6240\u6709\u7b49\u7ea7\u7528\u6237\u4fe1\u606f\u7684\u65e5\u5fd7\nkern.log #\u5185\u6838\u4ea7\u751f\u7684\u65e5\u5fd7\nlastlog #\u8bb0\u5f55\u6240\u6709\u7528\u6237\u7684\u6700\u8fd1\u4fe1\u606f\u3002\u9700\u8981\u7528lastlog\u547d\u4ee4\u67e5\u770b\u5185\u5bb9\nwtmp\u6216utmp #\u767b\u5f55\u4fe1\u606f\nbtmp #\u5931\u8d25\u767b\u5f55\u4fe1\u606f\u3002\u4f7f\u7528last\u547d\u4ee4\u67e5\u770b\u3002\u4f8b\u5982\uff0c\u201dlast -f \/var\/log\/btmp | more\u201c\u3002\nfaillog #\u767b\u5f55\u5931\u8d25\u4fe1\u606f\uff0c\u9519\u8bef\u767b\u5f55\u547d\u4ee4\u4e5f\u4f1a\u8bb0\u5f55\nyum.log #yum\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u4fe1\u606f\ncron #cron\u8fdb\u7a0b\u76f8\u5173\u4fe1\u606f\u8bb0\u5f55\nsecure #\u9a8c\u8bc1\u548c\u6388\u6743\u65b9\u9762\u4fe1\u606f\n```\n\n\n\n### \u7cfb\u7edf\n\n```\nuname -a \u00a0 # \u67e5\u770b\u5185\u6838\/\u64cd\u4f5c\u7cfb\u7edf\/CPU\u4fe1\u606f\u00a0\ncat \/etc\/issue\u00a0\ncat \/etc\/redhat-release # \u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u00a0\ncat \/proc\/cpuinfo \u00a0# \u67e5\u770bCPU\u4fe1\u606f\u00a0\nhostname \u00a0 # \u67e5\u770b\u8ba1\u7b97\u673a\u540d\u00a0\nlspci -tv \u00a0 # \u5217\u51fa\u6240\u6709PCI\u8bbe\u5907\u00a0\nlsusb -tv \u00a0 # \u5217\u51fa\u6240\u6709USB\u8bbe\u5907\u00a0\nlsmod \u00a0 \u00a0# \u5217\u51fa\u52a0\u8f7d\u7684\u5185\u6838\u6a21\u5757\u00a0\nenv \u00a0 \u00a0# \u67e5\u770b\u73af\u5883\u53d8\u91cf\u00a0\n```\n\n\n\n### \u8d44\u6e90\n\n```\nfree -m \u00a0 # \u67e5\u770b\u5185\u5b58\u4f7f\u7528\u91cf\u548c\u4ea4\u6362\u533a\u4f7f\u7528\u91cf\u00a0\ndf -h \u00a0 \u00a0 # \u67e5\u770b\u5404\u5206\u533a\u4f7f\u7528\u60c5\u51b5\u00a0\ndu -sh <\u76ee\u5f55\u540d> \u00a0 # \u67e5\u770b\u6307\u5b9a\u76ee\u5f55\u7684\u5927\u5c0f\u00a0\ngrep MemTotal \/proc\/meminfo # \u67e5\u770b\u5185\u5b58\u603b\u91cf\u00a0\ngrep MemFree \/proc\/meminfo # \u67e5\u770b\u7a7a\u95f2\u5185\u5b58\u91cf\u00a0\nuptime # \u67e5\u770b\u7cfb\u7edf\u8fd0\u884c\u65f6\u95f4\u3001\u7528\u6237\u6570\u3001\u8d1f\u8f7d\u00a0\ncat \/proc\/loadavg \u00a0 # \u67e5\u770b\u7cfb\u7edf\u8d1f\u8f7d\u00a0\n```\n\n\n\n### \u78c1\u76d8\u548c\u5206\u533a\n\n```\nmount | column -t \u00a0# \u67e5\u770b\u6302\u63a5\u7684\u5206\u533a\u72b6\u6001\u00a0\nfdisk -l \u00a0 # \u67e5\u770b\u6240\u6709\u5206\u533a\u00a0\nswapon -s \u00a0 # \u67e5\u770b\u6240\u6709\u4ea4\u6362\u5206\u533a\u00a0\nhdparm -i \/dev\/hda \u00a0# \u67e5\u770b\u78c1\u76d8\u53c2\u6570(\u4ec5\u9002\u7528\u4e8eIDE\u8bbe\u5907)\u00a0\ndmesg | grep IDE \u00a0# \u67e5\u770b\u542f\u52a8\u65f6IDE\u8bbe\u5907\u68c0\u6d4b\u72b6\u51b5\u00a0\n```\n\n\n\n### \u7f51\u7edc\n\n```\nifconfig \u00a0# \u67e5\u770b\u6240\u6709\u7f51\u7edc\u63a5\u53e3\u7684\u5c5e\u6027\u00a0\niptables -L \u00a0 # \u67e5\u770b\u9632\u706b\u5899\u8bbe\u7f6e\u00a0\nroute -n \u00a0 # \u67e5\u770b\u8def\u7531\u8868\u00a0\nnetstat -lntp \u00a0 # \u67e5\u770b\u6240\u6709\u76d1\u542c\u7aef\u53e3\u00a0\nnetstat -antp \u00a0 # \u67e5\u770b\u6240\u6709\u5df2\u7ecf\u5efa\u7acb\u7684\u8fde\u63a5\u00a0\nnetstat -s \u00a0 # \u67e5\u770b\u7f51\u7edc\u7edf\u8ba1\u4fe1\u606f\u00a0\n```\n\n\n\n### \u8fdb\u7a0b\n\n```\nps -ef \u00a0 # \u67e5\u770b\u6240\u6709\u8fdb\u7a0b\u00a0\ntop \u00a0 \u00a0# \u5b9e\u65f6\u663e\u793a\u8fdb\u7a0b\u72b6\u6001\uff08\u53e6\u4e00\u7bc7\u6587\u7ae0\u91cc\u9762\u6709\u8be6\u7ec6\u7684\u4ecb\u7ecd\uff09\u00a0\n```\n\n\n\n## \u7528\u6237\n\n```\nw \u00a0 \u00a0# \u67e5\u770b\u6d3b\u52a8\u7528\u6237\u00a0\nid <\u7528\u6237\u540d> \u00a0 # \u67e5\u770b\u6307\u5b9a\u7528\u6237\u4fe1\u606f\u00a0\nlast \u00a0 \u00a0# \u67e5\u770b\u7528\u6237\u767b\u5f55\u65e5\u5fd7\u00a0\ncut -d: -f1 \/etc\/passwd # \u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7528\u6237\u00a0\ncut -d: -f1 \/etc\/group # \u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7ec4\u00a0\ncrontab -l \u00a0 # \u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u8ba1\u5212\u4efb\u52a1\u00a0\n```\n\n\n\n## \u670d\u52a1\n\n```\nchkconfig \u2013list \u00a0# \u5217\u51fa\u6240\u6709\u7cfb\u7edf\u670d\u52a1\u00a0\nchkconfig \u2013list | grep on # \u5217\u51fa\u6240\u6709\u542f\u52a8\u7684\u7cfb\u7edf\u670d\u52a1\u00a0\n```\n\n\n\n## \u7a0b\u5e8f\n\n```\nrpm -qa \u00a0 # \u67e5\u770b\u6240\u6709\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\n```\n\n"}