How to obtain MAC address in Linux

Every network interface, on any device, has its own MAC address. Unlike IP addresses, which can change frequently and easily, MAC addresses are permanently tied to the hardware. Although you can spoof your MAC address with software, the real MAC address of your network interface will never change.

The MAC address identifies your device on the network. One common way they are used is for routers to hand out reserved IP addresses to a specific MAC address. To perform this configuration, you will first need to obtain your MAC address.

In this tutorial, you will learn how to obtain the MAC address on a Linux system via both command line and GUI. This will show you the MAC address for all network interfaces you have installed – for example, your Ethernet interface as well as your Wi-Fi network card.

In this tutorial you will learn:

  • How to obtain MAC address via command line
  • How to obtain MAC address via GUI
How to obtain MAC address in Linux
How to obtain MAC address in Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
DID YOU KNOW?
MAC stands for Media Access Control. The addresses are represented as six groups of two hexadecimal digits, and usually separated by colons. An example of a MAC address (sometimes called hardware address) looks like this: 08:00:27:ea:82:f9. Nearly all network interfaces use one, including Ethernet, Wi-Fi, and Bluetooth. Even virtual machine interfaces have one.

How to obtain MAC address in Linux step by step instructions




You will find the command line and GUI methods for obtaining your MAC address below. We recommend using the command line method, as it is universal across all Linux systems and should work regardless of which Linux distribution you are on.

Obtain MAC address via command line

  1. Start by opening a command line terminal and using the following ip command to view information for all installed network interfaces.
    $ ip a
    
  2. In the screenshot below, we have highlighted our MAC address for the enp0s3 interface. You should see yours listed, along with the MAC address for other installed network interfaces.
    Viewing the MAC address of a network interface via command line
    Viewing the MAC address of a network interface via command line

Obtain MAC address via GUI




The following instructions will vary depending on which desktop environment you are using. However, all desktop environments will provide a way for the user to obtain their MAC address. In the following screenshots, we are using the GNOME desktop environment. Adapt these instructions as needed for your own system.

  1. Open up your system’s network settings menu. On GNOME, we can access it by clicking the upper right corner and clicking on Wired Settings or Wi-Fi Settings in the case of a Wi-Fi interface.
    Opening the network settings menu via GUI
    Opening the network settings menu via GUI
  2. Open the settings panel for the network interface that you wish to obtain the MAC address of. In the case of GNOME, that is done by clicking on the corresponding cog wheel.
    Opening the settings panel for the network interface
    Opening the settings panel for the network interface
  3. Our MAC address can now be seen under the label of Hardware Address.
    Obtaining the MAC address for a network interface via GUI
    Obtaining the MAC address for a network interface via GUI


Closing Thoughts

In this tutorial, you saw how to obtain the MAC address of a network interface on a Linux system. This can be accomplished via either command line or GUI, with the command line option being more universal across all Linux distros. Now that you have your MAC address, you can use it to whitelist your device with a router or firewall, allocate a static IP address via DHCP, etc.



Comments and Discussions
Linux Forum