How to Find Your MAC Address on Ubuntu
At some point when running Ubuntu on your local machine or a server it can be useful to find out what your MAC address is. In this tutorial I will showcase three ways you can get hold of your MAC address or devices connected to your system.
What is a MAC Address?
A MAC address is a unique identifier assigned to a network interface controller. In short, it's used as a network address in communications within a network segment. A MAC address (Media Access Control Address) can be utilized as a unique identifier for individual devices on a network, specifically for Media Access Control.
A MAC address is built-up of a 12 digit hexadecimal and is tied to the Network Interface Controller (NIC). Most commonly, the MAC address is separated every second charater with a colon or a hyphen, creating the following format
XX-XX-XX-XX-XX-XX. However, in some rare instances the format might also be displayed without colon or hyphen separators
Use ip command to get your MAC address on Ubuntu
The MAC address is the link/ether field of the output. Mostly this will be present in the second line.
Run IP in your Terminal
ip command is a powerful tool for configuring network interfaces on Linux systems. You can use
ip to bring interfaces up or down, assign and remove addresses and routes, manage ARP cache, and much more.
Open up your terminal and run
ip link show
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65486 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 35:12:40:9c:61:47 brd ff:ff:ff:ff:ff:ff inet 192.168.127.245/12 brd 192.168.121.255 scope global dynamic eth0 valid_lft 2900sec preferred_lft 2900sec inet6 fe80::5854:ff:fe8c:6454/64 scope link valid_lft forever preferred_lft forever
The MAC address is the
link/ether field of the output.
Utilize ifconfig to find your MAC address on Ubuntu
Ifconfig stands for “interface configuration” and is used to view and change the configuration of network interfaces.
1. Install ifconfig on Ubuntu
ifconfig is a command-line tool that used to ship in all base installations of Ubuntu. However, as of Ubuntu 9.10 (Karmic Koala) this is no longer the case. I would suggest that you only utilize
ifconfig if you're running version of Ubunte released 2009 and erlier. With that said,
ifconfig can still be installed an latter versions of Ubuntu if need be.
2. Run ifconfig
ens1f0: flags=4163 mtu 1500 inet 10.124.202.230 netmas 255.255.255.128 broadcast 10.124.202.255 ether 70:ca:9b:ce:67:ae txqueuelen 1000 (Ethernet) RX packets 12187970 bytes 7390885300 (6.8 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16813496 bytes 16253942714 (15.1 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0xb1960000-b197ffff
Find your MAC address from /sys Directory
The /sys directory allows us to get information about your system and all of its components. Contents of this folder can be useful to identify attached and installed hardware in a familiar and structured way.
1. Navigate to /sys/class/net/interface-name/address
We can get the MAC address from the file /sys/class/net/interface-name/address.
2. Use cat to Print your MAC Address
We can make us of cat to print the contents of the file
/sys/class/net/eth0/address to your command-line.
3. Use cat to Print all MAC Addresses of your system
Sometimes it useful to see mac adresses of all devices connected to your system. By using cat again we can fetch all addresses at
61:86:ec:2l:18:6y 00:00:00:00:00:00 64:5a:ec:2l:18:45