Raspberry Pi

Commands Line Methods to Find Mac Address on Raspberry Pi

Media Access Control (Mac) address is a physical unique address number that always assigned to a network device for ease communication between network devices. Each network interface has its own Mac address and is represented with hexadecimal format. If you are a Raspberry Pi user and want to find Mac address, follow this article to find different command-line methods.

Command Line Methods to Find Mac Address on Raspberry Pi

You can find Mac address on Raspberry Pi through following methods:

Method 1: Find Mac Address Through “ip” Command

Easy way to find the Mac address of used network interface is to run the following “ip” command in the terminal:

$ ip link show

After executing the above command, you will get the Mac Address on Raspberry Pi.

Method 2: Find Mac Address Through “ifconfig” Command

Another simple command to show Mac Address is to run the “ifconfig” command. This command will show the detail of all available network interfaces on your Raspberry Pi device.

$ ifconfig

In order to find the Mac Address of specific module on Raspberry Pi, then execute the below ‘ifconfig’ command but with name of specific interface.

$ ifconfig <network-interface-name>

Method 3: Find Mac Address Through “cat” Command

Another simple method to retrieve the Mac Address of Raspberry Pi network interface is to use “cat” command. This command stores all information in the kernel directory, so, finding Mac Address of specific network interface is easy using this command.

$ cat /sys/class/net/<network-interface-name>/address

Method 4: Find Mac Address Through Python Library

The built-in Python tool on Raspberry Pi can also be utilized to figure out the Mac address of network interface on Raspberry Pi. Before proceeding to find Mac address, make sure you pip installed on your system. If not read this article to install it on Raspberry Pi.

Once, done, use the following command to instal a Python library for finding the Mac Address on Raspberry Pi:

 $ sudo pip install get-mac

Once the installation gets completed, now you have to create and open a Python file in your system using the “nano” editor:

$ nano macadd.py

Insert the following code inside the file.

from getmac import get_mac_address

 

wlan_mac = get_mac_address()

 

print(wlan_mac)

Then press “CTRL + X” key and type Y to save the file.

Now final step is to print the Mac address, all you have to do is to run the file using the following command:

$ python3 macadd.py

Conclusion

Mac address is a unique physical address assigned to network device for an easy communication. The above guidelines show you different methods to find the Mac address on Raspberry Pi. These methods include three different commands and a python library to get the Mac address on the terminal.

About the author

Muhammad Nasir

Hi! I am an engineer and technical blogger by profession and I enjoy getting things done with electronics. I am using this platform to share my knowledge in the field of Raspberry Pi, Linux, and Embedded Systems with others.