First you have to find your current IP address and netmask. If you don’t know what a netmask is, chances are you have a 24-bit netmask (which you may have seen in this format: 255.255.255.0).

The -sn option in nmap disables port scanning. This allows for a much faster, host discovery-only scan. After nmap is done, we are piping its output into grep, so that we can filter out our Raspberry Pi devices. The -B option stands for “before”, which means that grep will include the upper two lines of the output too. Without them we would only see the MAC address.

If you put this command in our ~/.bash_profile file with an alias, we can simply type “findpi” into a terminal and are done (see screenshot above)!