![Linux get mac address script](https://cdn1.cdnme.se/5447227/9-3/26_64e61dfee087c31b15931424.png)
![linux get mac address script linux get mac address script](https://i0.wp.com/ice786pk.com/wp-content/uploads/2017/12/get_mac_address_php.jpg)
I also needed to get the name of my network interfaces and I'll be using the arp one on my instances that don't know their single network device as well as their whole existance is entirely abstracted. Nobody is paying me so, that is all I have time for today. Also the interface eth0 may be present but is unused. Also on OS X the interface names are different. But what if instead of eth0 my interfaces start with eth1. I only tested my commands on my Kubuntu laptop. Get MAC address using shell script Loaded 0 Currently all the solution mentioned for getting the MAC address always use eth0. Also, find, arp, awk, sed, and sort are generally on every linux device already.
![linux get mac address script linux get mac address script](https://i.stack.imgur.com/r1JAz.png)
spaces, newlines, other weird characters.). Good chance network interfaces are not named in ways that break stuff the usual way (i.e. With a "clean list" of names, you can plug them into most other commands and test for the MAC address of all zeroes or a virtual attribute. It for sure includes my wifi network interface. I am not sure if that gets rid of the "virtual devices". With the arp command, you can specify "ethernet" devices. (explanation: gimme the arp table info | don't print if line 1, which are arp table headers | only print the fifth column | delete empty lines | aphabetize and remove duplicates) find /sys/class/net -type l -execdir basename '' | sed '/^$/d'| sort -u
![linux get mac address script linux get mac address script](https://i.ytimg.com/vi/FkiTOMn-XGw/maxresdefault.jpg)
I came up with two ways I thought were "okay". We need a "clean list of interfaces" that doesn't have the loopback.
![Linux get mac address script](https://cdn1.cdnme.se/5447227/9-3/26_64e61dfee087c31b15931424.png)