Terminal command to get MAC
You can access the address
file for each device on the
/sys
virtual filesystem. The MAC address should be in
/sys/class/net/<device-name>/address
.
to get mac address of any device you can use the command as :
$
cat /sys/class/net/*/address
Similarly we can also use the combination of ifconfig and grep
$ ifconfig -a | grep HWaddr | awk '{print $5}'
Similar commands:
- ifconfig -a
- ifconfig eth0
- ip link show
- ip -o link show eth0
- ip -o link show |cut -d ‘ ‘ -f 2,20
- cat /sys/class/net/*/address