3 Ways to Find MAC Address in Ubuntu Linux

Table of Contents


How to list MAC address on Ubuntu Linux is a commonly asked question during a Linux job interview. Here are 3 methods to get the MAC address in Ubuntu Linux. These commands are safe to run without changing anything.

  1. Find MAC address on Ubuntu with ifconfig
  2. Get MAC address with ip link show
  3. Find MAC address from /sys


Understanding MAC address

A MAC address (media access control address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment. MAC stands for Media Access Control, and each identifier is intended to be unique to a particular device.

The MAC address is tied to the Network Interface Controller (NIC), a subcomponent of the larger device.

The MAC address is a 12 digit hexadecimal number that is most often displayed with a colon or hypen separating every two digits (an octet), making it easier to read.

Example: A MAC address of 2c549188c9e3 is typically displayed as 2C:54:91:88:C9:E3 or 2c-54-91-88-c9-e3.

Find MAC address on Ubuntu with ifconfig

Ifconfig stands for “interface configuration.” It is used to view and change the configuration of the network interfaces on our system. On the latest Ubuntu version, this tool is no longer installed by default.

# ifconfig -a

ens1f0: flags=4163 mtu 1500
inet netmas broadcast
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

Get MAC address with ip link show in Ubuntu

The MAC address is the link/ether field of the output. Mostly this will be present in the second line.

# ip link show

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
link/ether 02:70:b1:b1:34:a1 brd ff:ff:ff:ff:ff:ff
inet brd scope global dynamic eth0
valid_lft 2301sec preferred_lft 2301sec
inet6 fe80::70:b1ff:feb1:34a1/64 scope link
valid_lft forever preferred_lft forever


Find MAC address from /sys

Directory /sys allows us to get information about the system and its components (mostly attached and installed hardware) in a structured way.

We can get the MAC address from the file /sys/class/net/interface-name/address.

# cat /sys/class/net/eth0/address

With the following command, we can get all the MAC address in the system.

$ cat /sys/class/net/*/address

Related Post:

3 Ways to Find IP address in Linux

4 Ways to Check Network Status on Linux

Share on facebook
Share on twitter
Share on linkedin
Liquid Web Managed Word Press