A MAC (Media Access Control) address is a unique value assigned to a network interface card (NIC, also called network adapter) by the manufacturer to uniquely identify it. This tutorial provides 2 methods how to get MAC address in the Linux.
Method 1 - ip command
ip command can be used to manage network interfaces. The following command prints the MAC address of each network interface:
ip -o link show | cut -d ' ' -f 2,20
lo: 00:00:00:00:00:00 ens33: 00:0c:29:2f:d4:6a
Method 2 - /sys/class/net directory
/sys/class/net contains information about the network interfaces available in the system. The following command allows getting MAC address of each network interface:
To get the MAC address of a specific network interface, use the following command: