1.
$ cat /sys/class/net/enp0s25/carrier
1
1表示接上,0表示没接上。
下面的命令表示网线状态是 UP还是DOWN:
$ cat /sys/class/net/enp0s25/operstate
up
Down的话可以用命令 UP起来:
ip link set dev eth1 up
2.使用 ethtool
$ ethtool enp0s25 | grep Link\ d
Cannot get wake-on-lan settings: Operation not permitted
Link detected: yes
3.使用 ifconfig
$ ifconfig enp0s25
enp0s25 Link encap:Ethernet HWaddr 00:21:cc:5d:29:ee
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:71434 errors:0 dropped:0 overruns:0 frame:0
TX packets:52989 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:69661987 (69.6 MB) TX bytes:9547733 (9.5 MB)
Interrupt:20 Memory:f5200000-f5220000
RUNNING 表示 检测到网线。