53

How can I see my mac address on Ubuntu?

Student
  • 837

8 Answers8

63

Update

As described in the newer answer below, the modern solution is to run:

ip addr show

The MAC address is shown in the link/ether field.

Original Answer

Open a terminal and run ifconfig:

ifconfig | grep HWaddr
Brian Kintz
  • 1,309
44

Use ip command instead of the outdated ifconfig

Command :

$ ip addr show

link/ether field of the output is the MAC address (Both for Wi-fi and ethernet connections, MAC address is represented by link/ether). Mostly this will be present in the second line.

Example :

$ ip addr show
1: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a0:54:9f:53:b2:6e brd ff:ff:ff:ff:ff:ff

In my case a0:54:9f:53:b2:6e is the MAC address.

Sandeep
  • 683
7

On Ubuntu 20.04.02 LTS, there is no HWaddr in the output from ifconfig. Instead, look at ether:

$ ifconfig | grep ether
Reyhn
  • 223
3

Try ifconfig, and look at the "HWaddr".

Ken
  • 31
2

okay, this is a very easy solution. 1/ Open a terminal 2/ ifconfig A list of network capable devices will be displayed. If you are using wireless, it usually is called wlan0, but can also be named pan0 wifi0 etc. A physical conection is most likely eth0. on the first line you will see your mac address. here is a sample of what you might see eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00

that's it.

You can spoof your mac address too with macchanger (sudo aptitude install macchanger) just type man macchanger to learn more

user
  • 21
2

You can also right-click on the GNOME Network Manager. There you choose connection information and the following window shows you the hardware address. See also NetworkManager at Ubuntus Wiki.

qbi
  • 661
1

Sometimes ip a won't show the physical mac address. i.e. if you're using a bond interface.

ethtool can be used to show the permanent mac address.

$ sudo ethtool -P eno2
Permanent address: b8:cb:29:aa:aa:aa

Where eno2 is your interface name.

Comparing this to the command used in other answers:

$ ip a sh dev eno2
3: eno2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
    link/ether 0e:0f:e0:aa:aa:aa brd ff:ff:ff:ff:ff:ff
Zikoat
  • 547
alphabet5
  • 111
0

To get the "primary" mac adress standalone that would be used to reach an external IP, try

ip route get 1 | awk '/dev/ {print $5}' | xargs -I{} cat /sys/class/net/{}/address
phil294
  • 349
  • 4
  • 14