JVMX
JVMX

Reputation: 1078

Shell command for getting mac address in OS X

I have been handicapped by the GUI and always seem to ask of help when it comes to the command line.

On Mac OS X only I need a command line to get the MAC address of the interface currently using WiFi.

Upvotes: 34

Views: 63626

Answers (7)

Nish
Nish

Reputation: 603

The command

networksetup -getairportnetwork en0 | cut -d ":" -f2 | xargs

will print just the SSID name.

Upvotes: 0

Pramodya Abeysinghe
Pramodya Abeysinghe

Reputation: 1210

Wifi mac address is normally can be found in en0. So you may try this command on Terminal

ifconfig en0 | awk '/ether/{print $2}'

Upvotes: 6

lac_dev
lac_dev

Reputation: 1449

This will easily give you the specific Mac Address for your Wifi Interface

networksetup -listallhardwareports | grep Wi-Fi -A 3 | awk '/Ethernet Address:/{print $3}'

Upvotes: 9

jarsever
jarsever

Reputation: 780

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

networksetup -listallhardwareports

It will return a nice list of devices like this:

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
===================

Upvotes: 34

nth
nth

Reputation: 1502

networksetup -getmacaddress <interface>

Upvotes: 12

beresfordt
beresfordt

Reputation: 5222

ifconfig en1 gets the interface details for wifi, the mac is on a line starting with ether, and is the second word on that line so:

ifconfig en1 | awk '/ether/{print $2}'

Upvotes: 59

vkuo
vkuo

Reputation: 360

ifconfig should do the trick, it'll display a bunch of info including your MAC address. Alternatively it'll be in your network settings under system preferences.

EDIT

On a computer with just a wireless connection, en0 will have your wifi settings. The tag labeled with ether will most likely be your MAC address.

If you have both a wired and wireless connection, it'll be under ether in the en1 tag

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

Upvotes: 6

Related Questions