{"id":697,"date":"2018-10-18T12:07:26","date_gmt":"2018-10-18T12:07:26","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=697"},"modified":"2018-10-18T15:56:47","modified_gmt":"2018-10-18T15:56:47","slug":"how-to-check-physical-network-cable-connection-status-on-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/18\/how-to-check-physical-network-cable-connection-status-on-linux\/","title":{"rendered":"how to check physical network cable connection status on linux ?"},"content":{"rendered":"<p>Method 1<\/p>\n<p>Using dmesg<\/p>\n<p>Using dmesg is one of the 1st things to do for inquiring current state of system:<\/p>\n<p>Example:<\/p>\n<p>dmesg | sed &#8216;\/eth.*Link is\/h;$;d&#8217;<\/p>\n<p>[1667676.292871] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx\/Tx<\/p>\n<p>Method 2<\/p>\n<p>\/sys\/class\/net\/<\/p>\n<p>cat \/sys\/class\/net\/eth0\/carrier<\/p>\n<p>1<\/p>\n<p>The number 1 in the above output means that the network cable is connection physically<br \/>\nto your&#8217;s network card slot.<\/p>\n<p>Or<\/p>\n<p>cat \/sys\/class\/net\/eth0\/operstate<\/p>\n<p>up<\/p>\n<p>Method 3<\/p>\n<p>Using ethtool command<\/p>\n<p>Syantax : ethtool interface_name | grep Link d<\/p>\n<p>Example:<\/p>\n<p>ethtool eth0 | grep Link d<\/p>\n<p>Link detected: yes<\/p>\n<p>we can use bash for loop again to check all network interfaces it once:<\/p>\n<p>for i in $( ls \/sys\/class\/net ); do echo -n $i; ethtool $i | grep Link d; done<\/p>\n<p>Sample output:<\/p>\n<p>eth0 Link detected: yes<br \/>\neth1 Link detected: no<br \/>\nlo Link detected: yes<br \/>\nwlan0 Link detected: no<\/p>\n<p>NOTE:<\/p>\n<p>The only problem with the above ethtool output is that it will not detect connected<\/p>\n<p>cable if your network interface is down. Consider a following example:<\/p>\n<p># ethtool eth0 | grep Link d<br \/>\nLink detected: yes<br \/>\n# ifconfig eth0 down<br \/>\n# ethtool eth0 | grep Link d<br \/>\nLink detected: no<br \/>\n# ifconfig eth0 up<br \/>\n# ethtool eth0 | grep Link d<br \/>\nLink detected: yes<\/p>\n<p><a href=\"https:\/\/www.linuxforfreshers.com\/2018\/03\/how-to-check-physical-network-cable.html\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Method 1 Using dmesg Using dmesg is one of the 1st things to do for inquiring current state of system: Example: dmesg | sed &#8216;\/eth.*Link is\/h;$;d&#8217; [1667676.292871] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx\/Tx Method 2 \/sys\/class\/net\/ cat \/sys\/class\/net\/eth0\/carrier 1 The number 1 in the above output means that &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/18\/how-to-check-physical-network-cable-connection-status-on-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;how to check physical network cable connection status on linux ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":827,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/697\/revisions\/827"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}