方法一:nmcli
输出中参数WIRED-PROPERTIES.CARRIER为on即为接网线网卡
#nmcli device show |grep -i -E "device|carrier"
GENERAL.DEVICE: ens224
WIRED-PROPERTIES.CARRIER: on
如下命令将输出内容合并为一行,只看{BANNED}{BANNED}{BANNED}{BANNED}{BANNED}最佳佳佳佳佳后一列为on即可
#nmcli device show |awk '/DEVICE/{t=$0}/CARRIER/{print t,$0}'
GENERAL.DEVICE: ens224 **WIRED-PROPERTIES.CARRIER: on
**
方法二:ifconfig
输出中状态为RUNNING的接口卡即为接网线网卡
# ifconfig |grep RUNNING
ens224: flags=4163RUNNING,MULTICAST> mtu 1500
方法三:ethtool来检查,主要关注的字段为"Link detected",注意如下的输出是插上网线的:
# ethtool ens224
Settings for ens224:
Supported ports: [ TP ]
Supported link modes: 1000baseT/Full
10000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: No
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 10000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
MDI-X: Unknown
Supports Wake-on: uag
Wake-on: d
Link detected: yes
手机扫一扫
移动阅读更方便
你可能感兴趣的文章