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:
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.
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.
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.
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:
Once the installation gets completed, now you have to create and open a Python file in your system using the “nano” editor:
Insert the following code inside the file.
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:
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.