一、发行版版本号
$ cat /etc/issue
Ubuntu 18.04 LTS \n \l
二、内核版本号
方法(1):
$ cat /proc/version
Linux version 4.15.0-99-generic (buildd@lcy01-amd64-013) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020
方法(2):
$ uname -a
Linux ubuntu 4.15.0-99-generic #100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
该命令会列出很多内容,含义如下
第一段:“Linux”,内核名称
第二段:“ubuntu”,主机名,等价于命令hostname
第三段:“4.15.0-99-generic”,内核发行版本号
第四段:"#100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020",内核版本,一般都带有构建日期
第五段:“x86_64”,硬件名称
第六段:“x86_64”,处理器类型
第七段:“x86_64”,硬件平台
第八段:“GNU/Linux”,操作系统
每段含义和命令可以通过uname --help
或man uname
查看
$ uname --help
Usage: uname [OPTION]...
Print certain system information. With no OPTION, same as -s.
-a, --all print all information, in the following order,
except omit -p and -i if unknown:
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type (non-portable)
-i, --hardware-platform print the hardware platform (non-portable)
-o, --operating-system print the operating system
--help display this help and exit
--version output version information and exit
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/uname>
or available locally via: info '(coreutils) uname invocation'
三、登录用户信息
方法(1)
$ who
ubuntu pts/1 2020-06-06 14:13 (10.68.4.59)
ubuntu pts/2 2020-06-06 22:10 (10.90.77.244)
方法(2)
$ w
14:51:44 up 2 days, 3:36, 7 users, load average: 6.01, 6.67, 6.83
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ubuntu pts/1 10.68.4.59 Sat14 5:48m 0.06s 0.31s sshd: ubuntu [priv]
ubuntu pts/2 10.90.77.244 Sat22 17:10m 0.05s 0.02s sshd: ubuntu [priv]
w命令除了显示得更详细以外,还记录了CPU的平均负载。
四、CPU信息
-
查看物理CPU个数
$ cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l 2
-
查看每个物理CPU中core的个数(即核数)
$ cat /proc/cpuinfo| grep "cpu cores"| uniq cpu cores : 14
-
查看逻辑CPU的个数
$ cat /proc/cpuinfo| grep "processor"| wc -l 56
-
查看CPU型号
$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 56 Intel(R) Xeon(R) CPU E5-2658 v4 @ 2.30GHz
从以上信息(1~4)可以看出该服务器有两个型号为"Intel Xeon"的CPU,该CPU的参数是14C28T(超线程)。这样算下来2个物理CPU总共28个物理核心,56个逻辑核心。
-
查看CPU负载
方法(1):$ uptime 14:11:39 up 2 days, 2:56, 6 users, load average: 2.64, 3.68, 3.81
该命令和
w
命令的第一行相同。它们的意思分别是当前时间为 14:11:39;系统已经运行了2天2小时56分钟;当前有6个用户登录;1分钟、5分钟、15分钟内系统的平均负荷(取值范围为[0,CPU数目])为"2.64, 3.68, 3.81",一般可以认为这个数值超过 CPU 数目时,CPU 将比较吃力的负载当前系统所包含的进程。方法(2):
$ top top - 14:24:58 up 2 days, 3:09, 6 users, load average: 3.71, 4.33, 4.08 Tasks: 1155 total, 2 running, 1153 sleeping, 0 stopped, 0 zombie %Cpu(s): 5.7 us, 2.9 sy, 0.0 ni, 91.2 id, 0.0 wa, 0.1 hi, 0.1 si, 0.0 st, 91.2 id_exact, 0.2 hi_exact, 0.3 irq_exact MiB Mem : 257034.1 total, 139392.9 free, 12337.6 used, 105303.6 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 240277.2 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
top命令比较大而全,它的第一行就是
uptime
命令的输出即CPU平均负载;第二行为进程的总体统计;第三行为CPU的实时负载统计;第四、五行为内存使用统计;剩下的就是每个进程的具体统计信息。top命令下能够响应如下常用按键:
h:显示帮助
s:改变画面更新频率
c:完整显示进程启动命令
n:设置在进程列表所显示进程的数量
E:改变第四、五行的内存显示单位
P:以 CPU 占用率大小的顺序排列进程列表
M:以内存占用率大小的顺序排列进程列表
q(ctrl+c):退出 top
五、内存信息
$ free -h
total used free shared buff/cache available
Mem: 251G 32G 95G 4.0G 122G 213G
Swap: 0B 0B 0B
该服务器总共251G内存;已使用32G;未使用95G;tmpfs使用4G;缓存使用122G;可用213G(缓存可被OS回收);未使用交换内存,交换内存只有在物理内存不够的时候才会使用。
六、磁盘信息
-
查看设备挂载的分区及其占用空间
方法(1):$ df -h 文件系统 容量 已用 可用 已用% 挂载点 udev 3.9G 0 3.9G 0% /dev tmpfs 788M 1.8M 786M 1% /run /dev/sdb3 92G 6.5G 81G 8% / tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/loop2 63M 63M 0 100% /snap/gtk-common-themes/1506 /dev/loop0 55M 55M 0 100% /snap/core18/1705 /dev/loop3 50M 50M 0 100% /snap/snap-store/433 /dev/loop4 28M 28M 0 100% /snap/snapd/7264 /dev/loop1 241M 241M 0 100% /snap/gnome-3-34-1804/24 /dev/sda3 96M 41M 56M 43% /boot/efi tmpfs 788M 32K 788M 1% /run/user/1000
方法(2):
$ lsblk -f NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT sda ├─sda1 ntfs C86692B16692A02C ├─sda2 vfat 9FE3-3132 ├─sda3 vfat A2AF-C8A9 55.2M 43% /boot/efi └─sda4 ntfs 恢复分区 DCEC5829EC57FBE8 sdb ├─sdb1 ntfs 新加卷 7A942BEA942BA799 ├─sdb2 vfat 4049-F369 └─sdb3 ext4 286575ce-e60e-45ce-a03e-35ed89511e43 80G 7% / sr0
方法(3):
$ fdisk -l Disk /dev/sdb:465.78 GiB,500107862016 字节,976773168 个扇区 Disk model: WDC WD5000LPVT-2 单元:扇区 / 1 * 512 = 512 字节 扇区大小(逻辑/物理):512 字节 / 4096 字节 I/O 大小(最小/最佳):4096 字节 / 4096 字节 磁盘标签类型:gpt 磁盘标识符:085AB157-9359-49AE-B7E1-8D64E7775DA3 设备 起点 末尾 扇区 大小 类型 /dev/sdb1 2048 645943295 645941248 308G Microsoft 基本数据 /dev/sdb2 645943296 646443007 499712 244M EFI 系统 /dev/sdb3 646443008 841754623 195311616 93.1G Linux 文件系统 Disk /dev/sda:119.25 GiB,128035676160 字节,250069680 个扇区 Disk model: Lenovo SSD SL700 单元:扇区 / 1 * 512 = 512 字节 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:gpt 磁盘标识符:715FF696-8E2B-11EA-8B31-28D2446F63B4 设备 起点 末尾 扇区 大小 类型 /dev/sda1 40 231938047 231938008 110.6G Microsoft 基本数据 /dev/sda2 231938048 248715263 16777216 8G Microsoft 基本数据 /dev/sda3 248715264 248920063 204800 100M EFI 系统 /dev/sda4 248920064 250064895 1144832 559M Windows 恢复环境
-
当前目录占用空间
$ du -h -d0 41M .
七、网络信息
-
查看IP地址
$ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.16.4 netmask 255.255.240.0 broadcast 192.168.31.255 inet6 fe80::f816:3eff:fef2:60ef prefixlen 64 scopeid 0x20<link> ether fa:16:3e:f2:60:ef txqueuelen 1000 (Ethernet) RX packets 16042182 bytes 2192704523 (2.0 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 21177090 bytes 3904138886 (3.6 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 2809496 bytes 1679887743 (1.5 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2809496 bytes 1679887743 (1.5 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
查看路由表
$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.16.1 0.0.0.0 UG 100 0 0 eth0 169.254.169.254 192.168.16.2 255.255.255.255 UGH 100 0 0 eth0 192.168.16.0 0.0.0.0 255.255.240.0 U 100 0 0 eth0
-
查看mac表
$ arp -a ? (192.168.16.2) at fa:16:3e:ad:71:2b [ether] on eth0 gateway (192.168.16.1) at fa:16:3e:ad:71:2b [ether] on eth0 ? (192.168.16.3) at fa:16:3e:ad:71:2b [ether] on eth0