howtouselinux

3 Ways to Find MAC Address In Linux

Table of Contents

 

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

The following Linux commands can be used to check MAC address.

  1. ifconfig -a
  2. ifconfig eth0
  3. ip link show
  4. ip -o link show eth0
  5. ip -o link show |cut -d ‘ ‘ -f 2,20
  6. cat /sys/class/net/*/address

 

What is MAC address?

From Wikipedia, A MAC address is the unique identifier that is assigned by the manufacturer to a piece of network hardware (like a wireless card or an ethernet card). MAC stands for Media Access Control, and each identifier is intended to be unique to a particular device.

A MAC address consists of six sets of two characters, each separated by a colon. 00:1B:44:11:3A:B7 is an example of a MAC address.

Find MAC address with ifconfig command in Linux

The best Linux command to find MAC address is using ifconfig command.  All we need is to open the terminal then type ifconfig -a in the prompt. The number next to ether is the MAC address. This command will list network interface name,Ip address, MTU size, etc.

# ifconfig -a

ens1f0: flags=4163 mtu 1500
inet 10.124.202.230 netmask 255.255.255.128 broadcast 10.124.202.255
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

Find MAC address with ip link show command in Linux

The second way to find MAC address is using “ip link show” command.  The number next to link/ether is the MAC address. This command will list the interface status, MAC address, MTU size, etc.

# ip link show

1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens1f0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 70:ca:9b:ce:67:ae brd ff:ff:ff:ff:ff:ff

The following command lists the interface names on the left and the associated MAC addresses on the right.

ip -o link show |cut -d ‘ ‘ -f 2,20
lo: 00:00:00:00:00:00
eth0: 02:01:e4:a2:3a:31

Find MAC address from /sys in Linux

# cat /sys/class/net/ens1f0/address
70:ca:9b:ce:67:ae

$ cat /sys/class/net/*/address
02:01:e4:a2:3a:31
00:00:00:00:00:00

 

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell (or command line).
Along the way you’ll learn the timeless skills handed down by generations of experienced, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

  • “This excellent Linux command line book is more than cubicle decoration, it’s a secret super power.” —Ken Hess, Red Hat
  • “For those looking to master the Linux command line and get an essential understand of the core Linux command line tools, this book is a highly effective and useful guide.” —Ben Rothke, RSA Conference
  • “I can honestly say I have found THE beginner’s guide to Linux.”
    Jayson Broughton, Linux Journal

Related Post:

3 Ways to Find IP address in Linux

4 Ways to Check Network Status on Linux

4 Ways to check Ubuntu Version

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Liquid Web Managed Word Press