【笔记】Linux常用命令

linux的一些常用命令记录

nmcli&bond

1
2
3
4
5
6
7
8
9
nmcli connection delete enp1s0f0
nmcli connection delete enp4s0f0
nmcli connection add ifname bond0 con-name bond0 type bond mode 4
nmcli connection add ifname enp1s0f0 con-name enp1s0f0 type bond-slave master bond0
nmcli connection add ifname enp4s0f0 con-name enp4s0f0 type bond-slave master bond0
nmcli connection modify bond0 ipv4.addresses 10.80.28.50/25 ipv4.gateway 10.80.28.126 ipv4.method manual ipv6.method ignore connection.autoconnect yes
nmcli connection up enp1s0f0
nmcli connection up enp4s0f0
nmcli connection up bond0

nmcli&team

1
2
3
4
5
nmcli conn add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}'
nmcli conn add con-name ens33 ifname ens33 type team-slave master team0
nmcli conn add con-name ens34 ifname ens34 type team-slave master team0
nmcli conn modify team0 ipv4.addresses 10.10.32.46/24 ipv4.gateway 10.10.32.254 ipv4.method manual
teamdctl team0 state

LVM

1
2
3
4
5
6
7
8
9
partprobe /dev/sdb
pvcreate /dev/sdb
vgcreate vg01 /dev/sdb
lvcreate -l 100%FREE -n data0 vg01
mkfs.xfs /dev/vg01/data0
mkdir /data0
blkid | grep data0
echo "UUID=$(blkid | grep data0 |grep -o 'UUID="[^"]*"' | awk -F'"' '{print $2}') /data0 xfs defaults 0 0" | sudo tee -a /etc/fstab
mount -a

挂载NAS

1
2
3
4
5
showmount -e [NAS IP]
vim /etc/fstab
[ip:目录] /挂载目录 nfs defaults 0 0
mount -a
df -hT

挂载iscsi

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#获取主机启动器的IQN
cat /etc/iscsi/initiatorname.iscsi

#查询iSCSI目标器(本端存储业务IP)
iscsiadm -m discovery -t st -p 10.10.10.22
iscsiadm -m discovery -t st -p 10.10.10.23

#建立iSCSI连接
iscsiadm -m node -p 10.10.10.22 -l
iscsiadm -m node -p 10.10.10.23 -l

#查看已连接的iSCSI会话
iscsiadm -m session

#重新扫描iSCSI启动器(也可通过hot_add命令重新扫描LUN)
iscsiadm -m session --rescan

#查询主机识别到的LUN信息
upadmin show vlun

#设置重启后自动连接目标器
iscsiadm -m node -o update -n node.startup -v automatic

eg:
[root@eStor03-host ~]# rpm -qa | grep iscsi
iscsi-initiator-utils-6.2.0.874-10.el7.x86_64
libvirt-daemon-driver-storage-iscsi-4.5.0-10.el7.x86_64
libiscsi-1.9.0-7.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.874-10.el7.x86_64
[root@eStor03-host ~]# systemctl restart iscsi
[root@eStor03-host ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:eStor03-host
[root@eStor03-host ~]# iscsiadm -m discovery -t st -p 10.10.10.12
10.10.10.12:3260,513 iqn.2014-08.com.example::2100050000040506::20200:10.10.10.12
[root@eStor03-host ~]# iscsiadm -m node -p 10.10.10.12 -l
Logging in to [iface: default, target: iqn.2014-08.com.example::2100050000040506::20200:10.10.10.12, portal: 10.10.10.12,3260] (multiple)
Login to [iface: default, target: iqn.2014-08.com.example::2100050000040506::20200:10.10.10.12, portal: 10.10.10.12,3260] successful.
[root@eStor03-host ~]# systemctl enable iscsi
[root@eStor03-host ~]# iscsiadm -m node -o update -n node.startup -v automatic
[root@eStor03-host ~]# systemctl restart iscsi

多路径multipath

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#先查看是否有/etc/multipath.conf文件,没有的话手动生成
/sbin/mpathconf --enable

在配置文件添加参数:
vim /etc/multipath.conf
devices{
device {
vendor "HUAWEI"
product "XSG1"
path_grouping_policy multibus
path_checker tur
prio const
path_selector "service-time 0"
failback immediate
dev_loss_tmo 30
fast_io_fail_tmo 5
no_path_retry 15
}
}
#重启服务并开机自启
systemctl restart multipathd.service
systemctl enable multipathd.service

#查看多路径
multipath -ll

本地Yum源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#挂载镜像
mount /dev/sr0 /mnt
#在/home目录下创建个目录用于拷贝镜像文件
mkdir /root/iso
cp -ra /mnt/* /root/iso/
vim /etc/yum.repo.d/base.repo
[base]
name=base
baseurl=file:///root/iso
enable=1
gpgcheck=0
yum clean all
yum makecache

#iso永久挂载
#如果目录下是iso文件
mount -o loop /iso/Kylin-2309b.iso /mnt/cdrom
vim /etc/fstab
/iso/Kylin-2309b.iso /mnt/cdrom iso9660 loop 0 0

PSSH

1
sshpass -p '@WSX2wsx' pssh -O StrictHostKeyChecking=no -h vm  -l root -A -i "dmidecode -s system-uuid"  | tee vm_kylin_sn_20231101.log

lsscsi与smartctl

查看当前系统下磁盘和单个磁盘的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
[root@shd-zhjg-mpp02 ~]# lsscsi
[4:0:0:0] disk ATA SAMSUNG MZ7L3960 304Q /dev/sda
[4:0:1:0] disk ATA SAMSUNG MZ7L3960 304Q /dev/sdb
[4:0:2:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdc
[4:0:3:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdd
[4:0:4:0] disk ATA ST8000NM000A-2KE SN02 /dev/sde
[4:0:5:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdf
[4:0:6:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdg
[4:0:7:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdh
[4:0:8:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdi
[4:0:9:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdj
[4:0:65:0] enclosu HUAWEI Expander 12G16T0 140 -
[4:2:0:0] disk AVAGO MR9460-8i 5.23 /dev/sdk

[root@shd-zhjg-mpp02 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 894.3G 0 disk
sdb 8:16 0 894.3G 0 disk
sdc 8:32 0 7.3T 0 disk
sdd 8:48 0 7.3T 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 7.3T 0 disk
sdg 8:96 0 7.3T 0 disk
sdh 8:112 0 7.3T 0 disk
sdi 8:128 0 7.3T 0 disk
sdj 8:144 0 7.3T 0 disk
sdk 8:160 0 7.3T 0 disk
├─sdk1 8:161 0 1G 0 part /boot/efi
├─sdk2 8:162 0 1G 0 part /boot
└─sdk3 8:163 0 7.3T 0 part
└─klas-root 252:0 0 7.3T 0 lvm /

[root@shd-zhjg-mpp02 ~]# lspci -i | grep AVAGO
lspci: option requires an argument -- 'i'
Usage: lspci [<switches>]

Basic display modes:
-mm Produce machine-readable output (single -m for an obsolete format)
-t Show bus tree

Display options:
-v Be verbose (-vv for very verbose)
-k Show kernel drivers handling each device
-x Show hex-dump of the standard part of the config space
-xxx Show hex-dump of the whole config space (dangerous; root only)
-xxxx Show hex-dump of the 4096-byte extended config space (root only)
-b Bus-centric view (addresses and IRQ's as seen by the bus)
-D Always show domain numbers
-P Display bridge path in addition to bus and device number
-PP Display bus path in addition to bus and device number

Resolving of device ID's to names:
-n Show numeric ID's
-nn Show both textual and numeric ID's (names & numbers)
-q Query the PCI ID database for unknown ID's via DNS
-qq As above, but re-query locally cached entries
-Q Query the PCI ID database for all ID's via DNS

Selection of devices:
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] Show only devices in selected slots
-d [<vendor>]:[<device>][:<class>] Show only devices with specified ID's

Other options:
-i <file> Use specified ID database instead of /usr/share/hwdata/pci.ids
-p <file> Look up kernel modules in a given file instead of default modules.pcimap
-M Enable `bus mapping' mode (dangerous; root only)

PCI access options:
-A <method> Use the specified PCI access method (see `-A help' for a list)
-O <par>=<val> Set PCI access parameter (see `-O help' for a list)
-G Enable PCI access debugging
-F <file> Read PCI configuration dump from a given file

[root@shd-zhjg-mpp02 ~]# lspci
00:00.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:04.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:08.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:0c.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:10.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:11.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
00:12.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCIe Root Port with Gen4 (rev 21)
01:00.0 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]
01:00.1 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]
02:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID Tri-Mode SAS3508 (rev 01)
04:00.0 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]
04:00.1 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]
05:00.0 Signal processing controller: Huawei Technologies Co., Ltd. iBMA Virtual Network Adapter (rev 01)
06:00.0 VGA compatible controller: Huawei Technologies Co., Ltd. Hi1710 [iBMC Intelligent Management system chip w/VGA support] (rev 01)
74:01.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCI-PCI Bridge (rev 20)
74:02.0 Serial Attached SCSI controller: Huawei Technologies Co., Ltd. HiSilicon SAS 3.0 HBA (rev 21)
74:03.0 SATA controller: Huawei Technologies Co., Ltd. HiSilicon AHCI HBA (rev 21)
74:04.0 Serial Attached SCSI controller: Huawei Technologies Co., Ltd. HiSilicon SAS 3.0 HBA (rev 21)
7a:00.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 1.1 Host Controller (rev 21)
7a:01.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 2.0 2-port Host Controller (rev 21)
7a:02.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 3.0 Host Controller (rev 21)
7b:00.0 System peripheral: Huawei Technologies Co., Ltd. HiSilicon Embedded DMA Engine (rev 21)
7c:00.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCI-PCI Bridge (rev 20)
7d:00.0 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21)
7d:00.1 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21)
7d:00.2 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21)
7d:00.3 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21)
b4:01.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCI-PCI Bridge (rev 20)
b4:02.0 Serial Attached SCSI controller: Huawei Technologies Co., Ltd. HiSilicon SAS 3.0 HBA (rev 21)
b4:03.0 SATA controller: Huawei Technologies Co., Ltd. HiSilicon AHCI HBA (rev 21)
b4:04.0 Serial Attached SCSI controller: Huawei Technologies Co., Ltd. HiSilicon SAS 3.0 HBA (rev 21)
ba:00.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 1.1 Host Controller (rev 21)
ba:01.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 2.0 2-port Host Controller (rev 21)
ba:02.0 USB controller: Huawei Technologies Co., Ltd. HiSilicon USB 3.0 Host Controller (rev 21)
bb:00.0 System peripheral: Huawei Technologies Co., Ltd. HiSilicon Embedded DMA Engine (rev 21)
bb:01.0 System peripheral: Huawei Technologies Co., Ltd. HiSilicon Internal SDI Function Engine (rev 21)
bb:02.0 System peripheral: Huawei Technologies Co., Ltd. Device a12b (rev 21)
bc:00.0 PCI bridge: Huawei Technologies Co., Ltd. HiSilicon PCI-PCI Bridge (rev 20)

[root@shd-zhjg-mpp02 ~]# lsscsi
[4:0:0:0] disk ATA SAMSUNG MZ7L3960 304Q /dev/sda
[4:0:1:0] disk ATA SAMSUNG MZ7L3960 304Q /dev/sdb
[4:0:2:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdc
[4:0:3:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdd
[4:0:4:0] disk ATA ST8000NM000A-2KE SN02 /dev/sde
[4:0:5:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdf
[4:0:6:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdg
[4:0:7:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdh
[4:0:8:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdi
[4:0:9:0] disk ATA ST8000NM000A-2KE SN02 /dev/sdj
[4:0:65:0] enclosu HUAWEI Expander 12G16T0 140 -
[4:2:0:0] disk AVAGO MR9460-8i 5.23 /dev/sdk
[root@shd-zhjg-mpp02 ~]# smartctl /dev/sda
smartctl 6.6 2017-11-05 r4594 [aarch64-linux-4.19.90-23.8.v2101.ky10.aarch64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

ATA device successfully opened

Use 'smartctl -a' (or '-x') to print SMART (and more) information

[root@shd-zhjg-mpp02 ~]# smartctl -a /dev/sda
smartctl 6.6 2017-11-05 r4594 [aarch64-linux-4.19.90-23.8.v2101.ky10.aarch64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model: SAMSUNG MZ7L3960HCJR-00B7C
Serial Number: S6KNNN0W522433
LU WWN Device Id: 5 002538 fa35333ee
Firmware Version: JXTC304Q
User Capacity: 960,197,124,096 bytes [960 GB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-4 T13/BSR INCITS 529 revision 5
SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Tue Nov 21 11:17:14 2023 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x53) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
No Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 60) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 719
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 16
177 Wear_Leveling_Count 0x0013 099 099 005 Pre-fail Always - 8
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 0
180 Unused_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 887
181 Program_Fail_Cnt_Total 0x0032 100 100 010 Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 010 Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 100 010 Pre-fail Always - 0
184 End-to-End_Error 0x0033 100 100 097 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 070 055 000 Old_age Always - 30
194 Temperature_Celsius 0x0022 070 055 000 Old_age Always - 30 (Min/Max 24/45)
195 Hardware_ECC_Recovered 0x001a 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 0
202 Unknown_SSD_Attribute 0x0033 100 100 010 Pre-fail Always - 0
235 Unknown_Attribute 0x0012 099 099 000 Old_age Always - 13
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 6064738867
242 Total_LBAs_Read 0x0032 099 099 000 Old_age Always - 11683537035
243 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
244 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
245 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 65535
246 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 65535
247 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 65535
251 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 9985165120

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Completed without error 00% 7 -

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
256 0 65535 Read_scanning was never started
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[root@shd-zhjg-mpp02 ~]#

netstat

netstat -ano查看服务和端口状态

ethtool

系统网卡与物理网卡对应关系:ethtool -p [device]

tee

将输出的结果写入文件,默认会覆盖
用法:[command] | tee [file]
tee.png
-a可以追加
参考:https://zhuanlan.zhihu.com/p/34510815

网卡配置

centos7

  1. nmtui图形化界面更改IP地址
  2. 配置文件:/etc/sysconfig/network-scripts/

Ubuntu 18.04 TLS

配置文件:/etc/netplannetplan apply使配置生效,ipaddr show查看网卡信息
image.png

SUSE

yast进入图形化界面或者配置文件/etc/sysconfig/network/
重启网卡:rcnetwork restart eth0wicked ifup eth0service network restart
关闭防火墙:service SuSEfirewall2_init stop
开机不启动防火墙:chkconfig SuSEfirewall2_init off

查看Linux服务是否启动

  1. 看进程

ps -ef | grep 服务名
ps aux | grep 服务名输出格式:USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
image.png

  1. 看端口

lsof -i:端口号
lsof -c [command]
image.png
image.png

查看Linux内核版本

  1. uname -a
    1
    2
    [root@oracle ~]# uname -a
    Linux oracle 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
  • Linux –内核名称。 如果在BSD或macOS上运行相同的命令,结果将有所不同。
  • oracle –主机名
  • 2.6.32-358.el6.x86_64 –内核版本
    • 2 –内核版本
    • 6 –重大修订
    • 32 –轻微修订
    • 358 –错误修复
  • #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 – 这意味着Ubuntu编译了5.3.0-28-generic 30次。最后的编译时间戳也在那里。
  • x86_64 –机器架构
  • x86_64 –处理器架构
  • x86_64 –操作系统体系结构(您可以在64位处理器上运行32位OS)
  • GNU/Linux –操作系统(不,它不会显示发行名称)
  1. cat /proc/version

    1
    2
    [root@oracle ~]# cat /proc/version
    Linux version 2.6.32-358.el6.x86_64 (mockbuild@x86-022.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Jan 29 11:47:41 EST 2013
  2. dmesg | grep linux

dmesg是用于编写内核消息的功能强大的命令。

1
2
3
4
5
6
7
8
9
10
[root@oracle ~]# dmesg | grep Linux
Linux version 2.6.32-358.el6.x86_64 (mockbuild@x86-022.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Jan 29 11:47:41 EST 2013
SELinux: Initializing.
SELinux: Starting in permissive mode
ACPI: BIOS _OSI(Linux) query ignored
SELinux: Registering netfilter hooks
- User ID: Red Hat Enterprise Linux Driver Update Program <secalert@redhat.com>
Linux agpgart interface v0.103
SELinux: Disabled at runtime.
SELinux: Unregistering netfilter hooks
  1. lsb_release -a

LSB( _Linux 标准库(Linux Standard Base)_)能够打印发行版的具体信息,包括发行版名称、版本号、代号等。

1
2
3
4
5
6
[root@oracle ~]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.4 (Santiago)
Release: 6.4
Codename: Santiago
  1. /etc/*-release
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [root@oracle ~]# cat /etc/issue
    Red Hat Enterprise Linux Server release 6.4 (Santiago)
    Kernel \r on an \m

    [root@oracle ~]# cat /etc/issue.net
    Red Hat Enterprise Linux Server release 6.4 (Santiago)
    Kernel \r on an \m

    [root@oracle ~]# cat /etc/lsb-release
    LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch