Shell command to get the MAC address in OS X

I was disappointed with the GUI and always seem to ask for help when it comes to the command line.

On Mac OS X, I only need the command line to get the MAC address of the wifi used.

Help!

+7
shell macos
source share
4 answers

ifconfig en1 gets the interface details for wifi, mac is in the line starting with ether, and is the second word on this line, therefore:

ifconfig en1 | awk '/ether/{print $2}' 
+22
source share
 networksetup -getmacaddress <interface> 
+6
source share

ifconfig should do the trick, it will display a ton of information, including your MAC address. Alternatively, it will be in the network settings in accordance with the system settings.

EDIT

On a computer with only a wireless connection, en0 will have your Wi-Fi settings. The tag marked with ether will most likely be your MAC address.

If you have a wired and wireless connection, it will be broadcast in the en1 tag

Source: http://m.iclarified.com/entry/index.php?enid=30929

+4
source share

I think the best and easiest way to get information is to use this command:

 networksetup -listallhardwareports 

It will return a good list of such devices:

 Hardware Port: USB 10/100/1000 LAN Device: en6 Ethernet Address: 00:e0:4c:... Hardware Port: Wi-Fi Device: en0 Ethernet Address: 80:e6:50:... Hardware Port: Bluetooth PAN Device: en3 Ethernet Address: 80:e6:50:... Hardware Port: Thunderbolt 1 Device: en1 Ethernet Address: 72:00:05:... Hardware Port: Thunderbolt 2 Device: en2 Ethernet Address: 72:00:05:... Hardware Port: Thunderbolt Bridge Device: bridge0 Ethernet Address: 72:00:05:... VLAN Configurations =================== 
+3
source share

All Articles