顯示安裝的系統版本
[root@VM_0_9_centos ~]# cat /etc/redhat-release [root@VM_0_9_centos ~]# cat /proc/version [root@VM_0_9_centos ~]# uname -r
顯示系統是多少位的(32/64bit)
getconf LONG_BIT
查看所有安裝的軟件包
//查看所有安裝的軟件包 [root@VM_0_9_centos ~]# rpm -qa
查看配置的環(huán)境變量
//查看配置的環(huán)境變量
[root@VM_0_9_centos ~]# env
查看當前用戶(hù)的計劃任務(wù)服務(wù)
// 查看當前用戶(hù)的計劃任務(wù)服務(wù) [root@VM_0_9_centos ~]# crontab -l
查看所有網(wǎng)絡(luò )接口的屬性,包括IP地址
// 查看所有網(wǎng)絡(luò )接口的屬性,包括IP地址 [root@VM_0_9_centos ~]# ifconfig
防火墻
//centos7的防火墻相關(guān):
firewall-cmd --state (防火墻狀態(tài))
systemctl list-unit-files|grep firewalld.service(防火墻狀態(tài))
systemctl restart firewalld.service(關(guān)閉防火墻)
systemctl disable firewalld.service(禁止開(kāi)機自動(dòng)啟動(dòng))
//centos7以下的防火墻相關(guān):
service iptables stop(關(guān)閉防火墻centos7以下)
chkconfig iptables off(禁止開(kāi)機自動(dòng)啟動(dòng))
內存/硬盤(pán)大小
//內存大小
[root@VM_0_9_centos ~]# cat /proc/meminfo |grep MemTotal
MemTotal: 1883616 kB
//硬盤(pán)大小
[root@VM_0_9_centos ~]# fdisk -l |grep Disk
查看系統內存情況
[root@VM_0_9_centos ~]# free
//查看內存總量 grep MemTotal /proc/meminfo //查看空閑內存量 grep MemFree /proc/meminfo
CPU大小
//查看CPU相關(guān)參數 [root@VM_0_9_centos ~]# cat /proc/cpuinfo
查看分區使用情況
// 查看所有分區 [root@VM_0_9_centos ~]# fdisk -l Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000c5e30 Device Boot Start End Blocks Id System /dev/vda1 * 2048 104857566 52427759+ 83 Linux //查看各分區使用情況 [root@VM_0_9_centos ~]# df -h
查看指定目錄的大小
//查看指定目錄的大小,不指定時(shí)默認是當前目錄 [root@VM_0_9_centos ~]# du -sh /software/ 2.1G /software/
查看用戶(hù)信息
[root@VM_0_9_centos ~]# w // 查看活動(dòng)用戶(hù) [root@VM_0_9_centos ~]# id // 查看指定用戶(hù)信息 [root@VM_0_9_centos ~]# last // 查看用戶(hù)登錄日志 [root@VM_0_9_centos ~]# cut -d: -f1 /etc/passwd // 查看系統所有用戶(hù) [root@VM_0_9_centos ~]# cut -d: -f1 /etc/group // 查看系統所有組
查看CPU信息的linux系統信息命令
//查看CPU信息的linux系統信息命令 [root@VM_0_9_centos ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 719 model name : Intel(R) Xeon(R) CPU xxxxxx stepping : 2 microcode : 0x1 cpu MHz : 2394.446 cache size : 4096 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 14 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch bmi1 avx2 bmi2 rdseed adx xsaveopt bogomips : 4788.89 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management:
查看系統運行/啟動(dòng)時(shí)間
//最清晰的查看方式 [root@VM_0_9_centos ~]# cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("系統已運行:%d天%d時(shí)%d分%d秒",run_days,run_hour,run_minute,run_second)}' 系統已運行:0天0時(shí)6分7秒 //who -b 查看最后一次系統啟動(dòng)的時(shí)間。 //who -r 查看當前系統運行時(shí)間 [root@VM_0_9_centos ~]# who -b system boot 2019-07-14 15:06 //系統上次啟動(dòng)時(shí)間 [root@VM_0_9_centos ~]# who -r run-level 3 2019-07-14 15:06 //last reboot可以看到Linux系統歷史啟動(dòng)的時(shí)間。 重啟一下操作系統后,然后 [root@VM_0_9_centos ~]# last reboot
//如果只需要查看最后一次Linux系統啟動(dòng)的時(shí)間 [root@VM_0_9_centos ~]# last reboot | head -1
reboot system boot 3.10.0-514.26.2. Sat Jul 7 21:25 - 19:16 (8+21:50)
// w命令查看,up后表示系統到目前運行了多久時(shí)間,反過(guò)來(lái)推算系統重啟時(shí)間 [root@VM_0_9_centos ~]# w 11:30:35 up 3 days, 18:38, 1 user, load average: 78.52, 73.84, 72.60 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 222.211.233.166 11:18 3.00s 0.02s 0.00s w //uptime 命令查看 [root@VM_0_9_centos ~]# uptime 11:33:18 up 3 days, 18:40, 1 user, load average: 71.31, 72.56, 72.30 //通過(guò)/proc/uptime查看 [root@VM_0_9_centos ~]# cat /proc/uptime 266.50 209.15//第一數字即是系統已運行的時(shí)間266.50秒 //運用系統工具date即可算出系統啟動(dòng)時(shí)間 [root@VM_0_9_centos ~]# date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S" 2018-06-28 16:52:24 [root@VM_0_9_centos ~]# cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("系統已運行:%d天%d時(shí)%d分%d秒",run_days,run_hour,run_minute,run_second)}' 系統已運行:0天0時(shí)6分7秒 //top命令 [root@VM_0_9_centos ~]# top top - 11:29:30 up 3 days, 18:37, 1 user, load average: 71.57, 72.68, 72.20 Tasks: 164 total, 70 running, 92 sleeping, 0 stopped, 2 zombie %Cpu(s): 13.0 us, 86.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st KiB Mem : 1883616 total, 75328 free, 804624 used, 1003664 buff/cache KiB Swap: 0 total, 0 free, 0 used. 642936 avail Mem //top命令說(shuō)明 第一行說(shuō)明: top – :系統當前時(shí)間 up:服務(wù)器連續運行的時(shí)間,筆者見(jiàn)過(guò)有服務(wù)器連續運行一年以上,linux服務(wù)器還是非常穩定的。 user:當前有多少用戶(hù)登錄系統 load average:這個(gè)邊有3個(gè)數值分別表示系統在前1分鐘,5分鐘,15分鐘的工作負載,一般單核負載在3-5之間比較合適,經(jīng)常在1以下,說(shuō)明cpu利用率不高,在5以上,cpu會(huì )處于較高負載狀態(tài),會(huì )容易宕機。 第二行就是顯示任務(wù)的數量情況,其中zombie要注意一下,這個(gè)是表示僵尸進(jìn)程,出現了僵尸進(jìn)程要注意下僵尸進(jìn)程是如何產(chǎn)生的。如果不找到產(chǎn)生原因,即使殺死了,可能也會(huì )再次出現。 第三行表示cpu的運行情況,按下1可以顯示每個(gè)核的運行情況。 第四行表示內存memory的使用情況。 第五行表示交換空間swap的使用情況。 下面顯示的就是進(jìn)程的運行狀態(tài)了。每個(gè)表頭表示的含義如下: PID:進(jìn)程編號 USER:進(jìn)程所屬用戶(hù) PR/NI:Priority/Nice value進(jìn)程執行的優(yōu)先順序 VIRT:Virtual Image (kb) 虛擬內存使用總額 RES:Resident size (kb) 常駐內存 SHR:Shared Mem size (kb) 共享內存 S:Process Status 進(jìn)程狀態(tài) %CPU:cpu使用率 %MEM:內存使用率 TIME+:進(jìn)程開(kāi)始運行時(shí)使用cpu的總時(shí)間 COMMAND:進(jìn)程運行的命令 在top狀態(tài)下按f可以查看表頭字段說(shuō)明。
更多命令
1、uname -a //查看內核/操作系統/CPU信息的linux系統信息命令 2、head -n 1 /etc/issue //查看操作系統版本,是數字1不是字母L 3、hostname //查看計算機名的linux系統信息命令 4、lsusb -tv //列出所有USB設備的linux系統信息命令 5、lspci -tv //列出所有PCI設備 6、lsmod //列出加載的內核模塊 7、cat /proc/loadavg // 查看系統負載磁盤(pán)和分區 8、mount | column -t // 查看掛接的分區狀態(tài) 9、swapon -s // 查看所有交換分區 10、hdparm -i /dev/hda // 查看磁盤(pán)參數(僅適用于IDE設備) 11、dmesg | grep IDE // 查看啟動(dòng)時(shí)IDE設備檢測狀況網(wǎng)絡(luò ) 12、iptables -L // 查看防火墻設置 13、route –n // 查看路由表 14、netstat -lntp // 查看所有監聽(tīng)端口 15、netstat -antp // 查看所有已經(jīng)建立的連接 16、netstat -s // 查看網(wǎng)絡(luò )統計信息進(jìn)程 17、ps -ef // 查看所有進(jìn)程 18、chkconfig –list // 列出所有系統服務(wù) 19、chkconfig –list | grep on // 列出所有啟動(dòng)的系統服務(wù)程序 20、cat /proc/partitions //查看linux硬盤(pán)和分區信息的系統信息命令 21、cat /proc/meminfo //查看linux系統內存信息的linux系統命令 22、cat /proc/ioports //查看設備io端口 23、cat /proc/interrupts //查看中斷 24、cat /proc/pci //查看pci設備的信息

