sodcalculator

10 Tech How-To

Get MAC Address in Ubuntu: 5 Quick Ways

Guide 10-24052 · Updated · Step by step

This guide shows you how to find the MAC address on any Ubuntu system, whether you’re using the desktop or just the command line. You’ll learn several methods, from the simplest one-liner to checking your network settings graphically. No extra software is needed—everything is built into Ubuntu.

What You’ll Need

  • An Ubuntu system (desktop or server)
  • Access to a terminal (Ctrl+Alt+T on desktop)
  • Sudo privileges if you need to check the MAC address of network interfaces other than your own (rarely required for basic lookup)

Step-by-Step

  1. Open a terminal. On Ubuntu desktop, press Ctrl+Alt+T. If you’re on a server, you’re already at the command line.
  2. Type the following command and press Enter:
    ip link show

    This shows all network interfaces. Look for lines starting with link/ether—the value right after is your MAC address. For example, link/ether 00:1a:2b:3c:4d:5e means the MAC is 00:1a:2b:3c:4d:5e.

  3. To see only your active interface (usually wlan0 or eth0), use:
    ip addr show

    Again, look for link/ether. The interface name is shown just above, like 2: wlp2s0.

  4. Use the older, simpler command if you prefer:
    ifconfig -a

    If ifconfig isn’t installed, install it with sudo apt install net-tools. The output shows HWaddr or ether depending on the version.

  5. For a clean, one-line output of just the MAC address, run:
    cat /sys/class/net/*/address

    This prints the MAC address for every interface, one per line. To get just the first one (usually your primary), use cat /sys/class/net/$(ip route show default | awk '{print $5}')/address.

  6. Graphical method (desktop only): Go to Settings → Network. Click the gear icon next to your connection (Wi-Fi or wired). In the Details tab, you’ll see Hardware Address—that’s your MAC.
  7. Check the MAC of a specific interface (e.g., eth0):
    ip link show eth0

    Replace eth0 with your actual interface name.

  8. To get a list of all interfaces with their MACs in a neat table, use:
    ip -o link show | awk '{print $2, $17}'

    This prints the interface name and its MAC address.

Common Mistakes

  • Confusing IP address with MAC address. The IP is the logical address (like 192.168.1.10), while the MAC is the physical hardware address (like 00:1a:2b:3c:4d:5e). Look for link/ether or HWaddr, not inet.
  • Using ifconfig without installing net-tools. Modern Ubuntu doesn’t include it by default. Use ip commands instead.
  • Reading the wrong line. In ip link show, the MAC is on the line that starts with link/ether, not the line with inet (which is the IP).
  • Forgetting that virtual interfaces (like docker0 or veth) also have MACs. If you see many addresses, your physical one is usually the one on your main interface (e.g., eth0, wlan0, enp3s0).

Tips

  • Use the ip command instead of ifconfig. It’s the modern standard and always installed.
  • Remember the format. MAC addresses are 12 hexadecimal digits, usually written in pairs separated by colons (e.g., 00:1a:2b:3c:4d:5e).
  • To copy the MAC quickly, use: ip link show | grep -o '..:..:..:..:..:..' | head -1—this extracts just the MAC.
  • If you need the MAC of a remote machine, you can use arp -a after pinging it, but this only works if it’s on the same local network.

Troubleshooting

No output from ip link show? Make sure you’re running it as a normal user—it doesn’t need sudo. If you still get nothing, your network drivers might not be loaded. Check with lspci | grep -i network or lsusb to see if your hardware is detected.

Getting a different MAC than expected? Some systems use a randomized MAC address for privacy, especially on Wi-Fi. Check your network settings—if “Random hardware address” is enabled, turn it off to see the permanent one.

You see a MAC like 00:00:00:00:00:00? This usually means the interface is down or not connected. Bring it up with sudo ip link set dev eth0 up (replace eth0) and try again.

Can’t find the interface name? Run ls /sys/class/net to list all interfaces. The ones like lo (loopback) and wlan0/eth0 are normal. If you see weird names like enp3s0, that’s just the predictable naming scheme used by modern Ubuntu.

Permission denied when reading /sys/class/net? That’s unusual—those files are world-readable. If you’re getting an error, check that the path is correct and you’re not trying to read a file inside a subdirectory.

Frequently Asked Questions

What is a MAC address used for?

A MAC address uniquely identifies your network interface on a local network. It’s used for communication within your LAN, for DHCP to assign IP addresses, and sometimes for MAC filtering in routers.

Can I change my MAC address in Ubuntu?

Yes, you can temporarily change it with sudo ip link set dev eth0 address XX:XX:XX:XX:XX:XX (replace eth0 and the address). This resets on reboot. To make it permanent, you’d need to configure it in netplan or NetworkManager.

Why do I see two MAC addresses for the same Wi-Fi adapter?

One is the permanent hardware MAC, and the other may be a randomized address used for privacy. Check your Wi-Fi settings to see if “Random hardware address” is enabled.

Does the MAC address change when I connect to different networks?

No, the hardware MAC is fixed by the manufacturer. However, if you have privacy features enabled, the OS might use a different random MAC for each network, so it appears to change.

Is the MAC address the same as the IP address?

No. The IP address is a logical address that can change, while the MAC is a physical address burned into your network card. They serve different purposes in networking.

How do I find the MAC address of my Bluetooth adapter?

Use hciconfig -a or bluetoothctl show. The MAC will be listed as “BD Address” or “Controller” address.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →