This is from my question and answer in Ask Ubuntu.
You can use the command
sudo nmap -sP -PE -PA21,23,80,3389 192.168.1.*
nmap: Network exploration tool and security / port scanner. From the manual:
-sP (Skip port scan): This option tells Nmap not to do a port scan
after host discovery, and only print out the available hosts that
responded to the scan. This is often known as a “ping scan”, but you
can also request that traceroute and NSE host scripts be run. This is by default one step more intrusive than the list
scan, and can often be used for the same purposes. It allows light reconnaissance of a target network
without attracting much attention. Knowing how many hosts are up is more valuable to attackers than
the list provided by list scan of every single IP and host name.
-PE; -PP; -PM (ICMP Ping Types):
In addition to the unusual TCP, UDP and SCTP host discovery types discussed previously, Nmap can send
the standard packets sent by the ubiquitous ping program. Nmap sends an ICMP type 8 (echo request)
packet to the target IP addresses, expecting a type 0 (echo reply) in return from available hosts..
Unfortunately for network explorers, many hosts and firewalls now block these packets, rather than
responding as required by RFC 1122. For this reason, ICMP-only scans are rarely reliable enough
against unknown targets over the Internet. But for system administrators monitoring an internal
network, they can be a practical and efficient approach. Use the -PE option to enable this echo
-PA port list (TCP ACK Ping):
The TCP ACK ping is quite similar to the just-discussed SYN ping. The difference, as you could likely guess, is that the TCP ACK flag is
set instead of the SYN flag. Such an ACK packet purports to be acknowledging data over an established TCP connection, but no such
connection exists. So remote hosts should always respond with a RST packet, disclosing their existence in the process.
The -PA option uses the same default port as the SYN probe (80) and can also take a list of destination ports in the same format. If an
unprivileged user tries this, the connect workaround discussed previously is used. This workaround is imperfect because connect is
actually sending a SYN packet rather than an ACK.
21,23,80,3389: Ports to search through.
192.168.1.*: Range of IPs. replace with yours.