How to find out the connected interface using linux command Rumi, October 26, 2020 Method 1 To find out the connected state of a network cable in Linux, just run: $ cat /sys/class/net/enp5s0/carrier Sample output: 1 If you got output as “1” (Number one), It means that the network cable is connected with the network card. Also, you can do this with the following command too: $ cat /sys/class/net/enp5s0/operstate Sample output: up Method 2: In case the above commands doesn’t help, there is another tool called “ethtool” to help you. ethtool is used to query and control network device driver and hardware settings, particularly for wired Ethernet devices. Run the following command to find out the connected state of a network cable: $ sudo ethtool enp5s0 Sample output: Settings for enp5s0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Link partner advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Link partner advertised pause frame use: Transmit-only Link partner advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000033 (51) drv probe ifdown ifup Link detected: yes To find out the state of wireless network card: $ sudo ethtool wlp9s0 Sample output: Settings for wlp9s0: Link detected: yes Let us disconnect the cable, and see what happens. $ sudo ethtool enp5s0 Sample output: Settings for enp5s0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Link partner advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Link partner advertised pause frame use: Transmit-only Link partner advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000033 (51) drv probe ifdown ifup Link detected: no Src: https://ostechnix.com/how-to-find-out-the-connected-state-of-a-network-cable-in-linux/ Administrations Collected Articles Ethtool