上一节,我们成功配置了免密登录Linux,接下来,我们可以在系统里面看看系统配置,主要有有这么几个命令:1.查看系统信息:hostnamectl
matthewfjnd@matthewfjndubuntu:~$ hostnamectl Static hostname: matthewfjndubuntu Icon name: computer-desktop Chassis: desktop 🖥️ Machine ID: 11111111111111111111111111111111 Boot ID: 22222222222222222222222222222222Operating System: Ubuntu 26.04 LTS Kernel: Linux 7.0.0-28-generic Architecture: x86-64 Hardware Vendor: Lenovo Hardware Model: ThinkCentre M920x-N000 Hardware SKU: LENOVO_MT_10S4_BU_Think_FM_ThinkCentre M920x-N000Firmware Version: M1UKT79A Firmware Date: Thu 2026-03-12 Firmware Age: 5month 1w 2d
2.查看内核版本:uname
有时候hostnamectl用不了,我们也可以用uname来显示一些系统的信息matthewfjnd@matthewfjndubuntu:~matthewfjnd@matthewfjndubuntu:~$ unameLinuxmatthewfjnd@matthewfjndubuntu:~$ uname -aLinux matthewfjndubuntu 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 GNU/Linuxmatthewfjnd@matthewfjndubuntu:~$ uname -r7.0.0-28-genericnbsp;unameLinuxmatthewfjnd@matthewfjndubuntu:~matthewfjnd@matthewfjndubuntu:~$ unameLinuxmatthewfjnd@matthewfjndubuntu:~$ uname -aLinux matthewfjndubuntu 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 GNU/Linuxmatthewfjnd@matthewfjndubuntu:~$ uname -r7.0.0-28-genericnbsp;uname -aLinux matthewfjndubuntu 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 GNU/Linuxmatthewfjnd@matthewfjndubuntu:~matthewfjnd@matthewfjndubuntu:~$ unameLinuxmatthewfjnd@matthewfjndubuntu:~$ uname -aLinux matthewfjndubuntu 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 GNU/Linuxmatthewfjnd@matthewfjndubuntu:~$ uname -r7.0.0-28-genericnbsp;uname -r7.0.0-28-generic
Kernel: Linux 7.0.0-28-generic
都显示了Ubuntu 26.04的内核版本是Linux 7.0.0。有一些特性,是新内核才有,有一些驱动需要新内核才能安装上。PS:所谓内核,是一个操作系统的核心。它负责管理系统的进程、内存、设备驱动程序、文件和网络系统等等,是连接应用程序和硬件的桥梁。现在内核的主要分类有四类:宏内核,微内核,混合内核,外内核。这几种内核的代表系统,这里列举几个:宏内核的代表系统是Linux、Unix以及安卓(安卓是在Linux的基础上改的);微内核的代表系统是鸿蒙(之前诺基亚的塞班系统也是微内核);混合内核的代表是Windows,苹果的IOS也算混合内核(IOS是在Unix基础上改的);外内核比较少见,只听说过Nemesis。因此,说鸿蒙是安卓,是不准确的。内核都不一样。关于系统内核,后面我会开一个小系列来讲解。3.查看CPU:lscpu
matthewfjnd@matthewfjndubuntu:~$ lscpuArchitecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little EndianCPU(s): 16 On-line CPU(s) list: 0-15Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i9-9900T CPU @ 2.10GHz CPU family: 6 Model: 158 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 13 CPU(s) scaling MHz: 33% CPU max MHz: 4400.0000 CPU min MHz: 800.0000 BogoMIPS: 4199.88 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_go od nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm 2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsa ve avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced t pr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx r dseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp _notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilitiesVirtualization features: Virtualization: VT-xCaches (sum of all): L1d: 256 KiB (8 instances) L1i: 256 KiB (8 instances) L2: 2 MiB (8 instances) L3: 16 MiB (1 instance)NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-15Vulnerabilities: Gather data sampling: Vulnerable Ghostwrite: Not affected Indirect target selection: Mitigation; Aligned branch/return thunks Itlb multihit: KVM: Mitigation: Split huge pages L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Old microcode: Not affected Reg file data sampling: Not affected Retbleed: Mitigation; Enhanced IBRS Spec rstack overflow: Not affected Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KV M SW loop Srbds: Mitigation; Microcode Tsa: Not affected Tsx async abort: Mitigation; TSX disabled Vmscape: Mitigation; IBPB before exit to userspace
4.查看硬盘:lsblk
我们可以用list block(列出块)来记忆。至于为什么是block(块),是因为存储的类型有块存储、对象存储、文件存储等,我们是将1T的硬盘接到了M.2的接口上,直接使用硬盘,也就是块存储,所以是block。关于存储类型,后面我会开一个小系列来讲解。matthewfjnd@matthewfjndubuntu:~matthewfjnd@matthewfjndubuntu:~$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSnvme0n1 259:0 0 953.9G 0 disk|-nvme0n1p1 259:1 0 1G 0 part /boot/efi|-nvme0n1p2 259:2 0 2G 0 part /boot`-nvme0n1p3 259:3 0 950.8G 0 part `-ubuntu--vg-ubuntu--lv 252:0 0 100G 0 lvm /nbsp;lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSnvme0n1 259:0 0 953.9G 0 disk|-nvme0n1p1 259:1 0 1G 0 part /boot/efi|-nvme0n1p2 259:2 0 2G 0 part /boot`-nvme0n1p3 259:3 0 950.8G 0 part `-ubuntu--vg-ubuntu--lv 252:0 0 100G 0 lvm /
这里我们我们记一下,nvme0n1的SIZE是953.9G,也就是1T。下面的nvme0n1p1的SIZE是1G,挂载点是/boot/efi、nvme0n1p2的SIZE是2G,挂载点是/boot。需要注意的是,nvme0n1p3的SIZE是950.8G,后面没有显示挂载点,下面的ubuntu--vg-ubuntu--lv的SIZE是100G,挂载点是/。这里有几个知识点,一个是挂载点,一个是Linux的系统分区、一个是动态磁盘。关于以上知识点,后面我会分别来讲解。5.查看内存:free
这个命令很奇怪,用free(自由、空闲)来查看内存。我只能用“查看还剩下(free)多少内存”来记忆matthewfjnd@matthewfjndubuntu:~$ free total used free shared buff/cache availableMem: 64624260 1116240 62369844 1440 1827728 63508020Swap: 8388604 0 8388604matthewfjnd@matthewfjndubuntu:~$ free -h total used free shared buff/cache availableMem: 61Gi 1.1Gi 59Gi 1.4Mi 1.7Gi 60GiSwap: 8.0Gi 0B 8.0Gi
其中,free -h,是以human(人类)易读的方式,显示单位。6.查看PCI设备:lspci
matthewfjnd@matthewfjndubuntu:~$ lspci00:00.0 Host bridge: Intel Corporation 8th/9th Gen Core 8-core Desktop Processor Host Bridge/DRAM Registers [Coffee Lake S] (rev 0d)00:01.0 PCI bridge: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) (rev 0d)00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-S GT2 [UHD Graphics 630] (rev 02)00:08.0 System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller (rev 10)00:14.2 RAM memory: Intel Corporation Cannon Lake PCH Shared SRAM (rev 10)00:14.3 Network controller: Intel Corporation Cannon Lake PCH CNVi WiFi (rev 10)00:16.0 Communication controller: Intel Corporation Cannon Lake PCH HECI Controller (rev 10)00:16.3 Serial controller: Intel Corporation Cannon Lake PCH Active Management Technology - SOL (rev 10)00:17.0 SATA controller: Intel Corporation Cannon Lake PCH SATA AHCI Controller (rev 10)00:1b.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #21 (rev f0)00:1f.0 ISA bridge: Intel Corporation Q370 Chipset LPC/eSPI Controller (rev 10)00:1f.3 Audio device: Intel Corporation Cannon Lake PCH cAVS (rev 10)00:1f.4 SMBus: Intel Corporation Cannon Lake PCH SMBus Controller (rev 10)00:1f.5 Serial bus controller: Intel Corporation Cannon Lake PCH SPI Controller (rev 10)00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (7) I219-LM (rev 10)01:00.0 3D controller: NVIDIA Corporation GP104GL [Tesla P4] (rev a1)02:00.0 Non-Volatile memory controller: Silicon Motion, Inc. SM2262/SM2262EN SSD Controller (rev 03)
在这里,我们可以看到00:00.0、00:1f.3、01:00.0这些数字。这些是PCI和PCIe设备的硬件地址,在Linux中被称为BDF标识符(Bus, Device, Function,即总线-设备-功能),格式是 [总线]:[设备].[功能],全部采用十六进制表示。关于PCI等硬件的相关知识,后面我会开一个小系列来讲解。