Nmap is a very useful tool. It is used by penetration testers mainly but from an operation perspective, it is used by system administrators too. Nmap has a lot of different features. The mac-related feature can be used to get mac addresses of the hosts in the same network segment. I can be used to get remote systems mac addresses but SNMP should be enabled on remote systems.
Get Mac Address Of Local System
Getting local systems mac address is easy and have a lot of different ways. Here we simply use IP tools.
$ ip link

Get Mac Address Of Remote But Same Network System
We can use Nmap to get mac address of a host if we are in the same network segment.
$ sudo nmap -sP -n 192.168.122.0/24

Get Mac Address Of Remote System With Snmp
The more complicated way is using SNMP service. SNMP tools can be used to get the mac address of the hosts. Here we use Nmap SNMP script to query SNMP service simply.
$ sudo nmap -sU -p 161 -T4 -d -v -n -Pn --script snmp-interfaces ubu1

good job
`-Pn` is depricated. Use `-sn`