How to Look Up a MAC Address in Linux?

A MAC address, also known as hardware or a physical address, stands for Media Access Control address. It is usually formatted as six pairs of hexadecimal digits, separated by colons (e.g., 00:11:22:33:44:55) which is a 48-bit number. The MAC address contains information about the device, such as its manufacturer and type.

This post will provide a list of methods to look for a MAC address in Linux.

Method 1: How to Look Up a MAC Address in Linux Through Command Line?

A few commands are used to find the MAC addresses of the devices through the command line, which includes the following.

The ip link Command

Using the ip link command, users can find the MAC addresses of each device by following the syntax mentioned below:

$ ip link

In the above image, the string in the box is the MAC address of “ens33,” which can differ depending on your connection. It can either be a “wlan0, eth0, or enpls0,” and the zeroes can be either “1, 2, or 3”.

Using ip link Command With grep

If you’re having difficulty knowing the MAC address, use the Ip link command with grep as in this format.

$ ip link show ens33 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

The above command works as follows:

  • The command “Ip link show ens33” displays information about the network interface “ens33”.
  • The output of this command is then passed to the “grep” command, which searches for lines that match a specified pattern.
  • The “-o” option is used to print the matching portion of the line, rather than the complete line.
  • The “-E” option tells grep to use extended regular expressions for the pattern.
  • The pattern “([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}” is used to search for the MAC address of the network interface.

The ifconfig Command

The ifconfig command is primarily used to find the IP addresses. Still, you can also use it to find your MAC address as well as shown below:

$ ifconfig

Using ifconfig With grep

If you only want to see the MAC address of a specific connection (ens33 in our case), use this command just like you did in the previous section:

$ ifconfig ens33 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

If we look at the above command, the grep parameters are the same as we used in the ip link command. Finally, the output has shown the MAC address only on the terminal.

Method 2: How to Look Up MAC Addresses in Linux through the GUI?

To look up the MAC address of your network device, you need to go to settings and click on the “Network” tab. After that, click on the wheel-like button under the “Connection (Wired in our case),” highlighted below.

A new menu will pop up that basically is the advanced settings of the network, and here you will see different settings and information, including the MAC address highlighted in the below image.

The hardware address represents the MAC address of the currently selected network device.

Conclusion

MAC addresses of the devices, such as networks or Bluetooth, can be checked using the command line and the graphical interface. For the command line, use the ‘ifconfig’ and the ‘iplink’ commands in the terminal. While the networks settings option in the GUI of Linux will give you the initial details about the MAC addresses. All these methods are practically demonstrated in this post.