This is an old revision of the document!
Overview
Discussion about how net cable connect and disconnect are reflected in /sys.
/sys/class/net/enp3s0/ files
-r--r--r--. 1 root root 4096 Aug 1 10:41 addr_assign_type -r--r--r--. 1 root root 4096 Aug 1 10:41 address -r--r--r--. 1 root root 4096 Aug 1 10:41 addr_len -r--r--r--. 1 root root 4096 Aug 1 10:41 broadcast -rw-r--r--. 1 root root 4096 Aug 1 10:41 carrier -r--r--r--. 1 root root 4096 Aug 1 10:41 carrier_changes -r--r--r--. 1 root root 4096 Aug 1 10:41 carrier_down_count -r--r--r--. 1 root root 4096 Aug 1 10:41 carrier_up_count lrwxrwxrwx. 1 root root 0 Aug 1 07:13 device -> ../../../0000:03:00.0 -r--r--r--. 1 root root 4096 Aug 1 10:41 dev_id -r--r--r--. 1 root root 4096 Aug 1 10:41 dev_port -r--r--r--. 1 root root 4096 Aug 1 10:41 dormant -r--r--r--. 1 root root 4096 Aug 1 10:41 duplex -rw-r--r--. 1 root root 4096 Aug 1 10:41 flags -rw-r--r--. 1 root root 4096 Aug 1 10:41 gro_flush_timeout -rw-r--r--. 1 root root 4096 Aug 1 10:41 ifalias -r--r--r--. 1 root root 4096 Aug 1 10:41 ifindex -r--r--r--. 1 root root 4096 Aug 1 10:41 iflink -r--r--r--. 1 root root 4096 Aug 1 10:41 link_mode -rw-r--r--. 1 root root 4096 Aug 1 10:41 mtu -r--r--r--. 1 root root 4096 Aug 1 10:41 name_assign_type -rw-r--r--. 1 root root 4096 Aug 1 10:41 netdev_group -r--r--r--. 1 root root 4096 Aug 1 10:41 operstate -r--r--r--. 1 root root 4096 Aug 1 10:41 phys_port_id -r--r--r--. 1 root root 4096 Aug 1 10:41 phys_port_name -r--r--r--. 1 root root 4096 Aug 1 10:41 phys_switch_id drwxr-xr-x. 2 root root 0 Aug 1 10:41 power -rw-r--r--. 1 root root 4096 Aug 1 10:41 proto_down drwxr-xr-x. 4 root root 0 Aug 1 10:41 queues -r--r--r--. 1 root root 4096 Aug 1 10:41 speed drwxr-xr-x. 2 root root 0 Aug 1 10:41 statistics lrwxrwxrwx. 1 root root 0 Aug 1 07:13 subsystem -> ../../../../../../class/net -rw-r--r--. 1 root root 4096 Aug 1 10:41 tx_queue_len -r--r--r--. 1 root root 4096 Aug 1 10:41 type -rw-r--r--. 1 root root 4096 Aug 1 10:41 uevent
In particular, we care about the attributes that reflect physical connection (note how carrier is writeable):
-rw-r--r--. 1 root root 4096 Aug 1 10:41 carrier [0 or 1] -r--r--r--. 1 root root 4096 Aug 1 10:41 operstate [up or down] -rw-r--r--. 1 root root 4096 Aug 1 10:41 flags