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.
- Find MAC address on Ubuntu with ifconfig
- Get MAC address with ip link show
- Find MAC address from /sys
Table of Contents
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
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
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