Display list of computers on a LAN in Linux
Get nmap. It's the program Trinity used in The Matrix and you can do a scan to find all of the devices that are connected to the LAN you're on and more.
Here's the reference guide.
This is what I use, nmap, and an address using CIDR block notation of the network you want to scan. First you need to install nmap as it may not come pre-installed with you distro. On Ubuntu:
sudo apt-get install nmap
Next figure out your network address by using ifconfig:
ifconfig
ifconfig output for the interface I want to scan:
wlan1 Link encap:Ethernet HWaddr 00:1f:3b:03:d2:bf
inet addr:192.168.1.104 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21f:3bff:fe03:d2bf/64 Scope:Link
...
Use the inet addr and Mask to figure out the network address in CIDR notation, more on CIDR here. The address is:
192.168.1.0/24
Run nmap using -sP parameter, which will scan no further than checking if the host is online:
sudo nmap -sP 192.168.1.0/24
nmap output will look something like this:
Starting Nmap 5.21 ( http://nmap.org ) at 2014-12-09 10:52 EST
Nmap scan report for 192.168.1.1
Host is up (0.013s latency).
MAC Address: -MAC ADDRESS- (Cameo Communications)
...
Nmap done: 256 IP addresses (5 hosts up) scanned in 3.26 seconds
That's it, if you need more help with nmap, see the nmap official documentation, or run:
nmap --help
arp -n
only shows you machines on your LAN that your machine has already talked to. You can get that list to populate better by pinging the broadcast and all-hosts multicasts addresses:
The "all ones" (in binary) broadcast address. Note that most IP stacks will translate this to the subnet broadcast addresses for all subnets you're attached to:
ping 255.255.255.255
The subnet broadcast address for your current subnet. So assuming you're on 192.168.1.0/24:
ping 192.168.1.255
The "all hosts" multicast address. I like this one a lot because it's more likely to find hosts configured for other IP subnets, that happen to be attached to the same Ethernet LAN as you:
ping 224.0.0.1
Note that this method, and the other methods I've seen mentioned in other Answers so far, only look for IP-reachable hosts on the current network. That's probably all you need to care about, but it's possible for an attacker to snoop on, or do bad things to, a network without being visible via IP.