sodcalculator

10 Tech How-To

How to Scan for Wi-Fi Networks in Ubuntu Server

Guide 10-56521 · Updated · Step by step

This guide shows you how to discover nearby Wi-Fi networks from the command line on Ubuntu Server. You’ll learn the essential commands to list available access points, check signal strength, and identify security types—useful when setting up a headless server or troubleshooting wireless connectivity.

What You’ll Need

  • A machine running Ubuntu Server (20.04 or newer) with a wireless network interface.
  • Root or sudo access to install packages and run scanning commands.
  • An active internet connection (optional, but needed to install missing tools).
  • Physical or remote access to the terminal (SSH works fine).

Step-by-Step

  1. Identify your wireless interface. Run ip link show or iw dev to list network interfaces. Look for a name like wlan0 or wlx.... If you don’t see one, your Wi-Fi adapter may not be recognized (see Troubleshooting).
  2. Check if the interface is up. Use ip link set wlan0 up (replace wlan0 with your interface name). You may need sudo. If it’s already up, you’ll see state UP in the output.
  3. Install the necessary tools. Most Ubuntu Server installs include iw and wpa_supplicant, but if not, install them with: sudo apt update && sudo apt install iw wireless-tools. This provides the iw and iwlist commands.
  4. Scan using iw (recommended). Run sudo iw dev wlan0 scan | grep -E "SSID|signal|freq". This shows the network name (SSID), signal strength in dBm, and frequency. If you want the full details, omit the grep and just run sudo iw dev wlan0 scan.
  5. Scan using iwlist (alternative). If you prefer a more traditional output, run sudo iwlist wlan0 scan. This lists all networks with ESSID, channel, quality, and encryption info. To get a clean list of SSIDs, use: sudo iwlist wlan0 scan | grep ESSID.
  6. Interpret the results. The scan output shows each network’s SSID, BSSID (MAC address), signal level (e.g., -60 dBm), channel, and security (e.g., WPA2). A signal closer to 0 dBm is stronger; -70 dBm or lower is weak.
  7. Scan without sudo (optional). Some systems allow scanning as a regular user if the interface is set to allow it. Try iw dev wlan0 scan without sudo. If you get a permission error, stick with sudo.
  8. Use a one-liner for a quick overview. To see just SSID and signal strength, run: sudo iw dev wlan0 scan | awk -F': ' '/SSID/{ssid=$2} /signal/{print $2" dBm - "ssid}'. This gives a compact list.

Common Mistakes

  • Forgetting sudo. Wireless scanning typically requires root privileges. Running iw dev wlan0 scan without sudo often fails with “Operation not permitted.”
  • Using the wrong interface name. On some systems, the Wi-Fi interface is named wlx001122334455 (based on MAC) rather than wlan0. Always check with ip link first.
  • Interface is down. If the interface is administratively down, the scan will return nothing. Bring it up with ip link set wlan0 up first.
  • Not installing tools. Minimal Ubuntu Server installs may lack iw or iwlist. If you get “command not found”, install them as shown in Step 3.
  • Confusing dBm with percentage. Signal strength is shown in dBm (negative values). A value like -50 dBm is better than -80 dBm. Don’t mistake it for a percentage.

Tips

  • Use watch for continuous scanning. To monitor networks over time, run sudo watch -n 2 'iw dev wlan0 scan | grep SSID'. This refreshes every 2 seconds.
  • Filter for 5 GHz networks. Add grep -E "freq: 5" to see only 5 GHz networks, which often have less interference.
  • Check supported frequencies. Run iw phy phy0 info | grep -A 10 "Band 2" to see which channels your adapter supports.
  • Save scan results to a file. Redirect output with sudo iw dev wlan0 scan > scan.txt for later analysis.
  • Use nmcli if NetworkManager is installed. On desktop-oriented Ubuntu Server setups, nmcli dev wifi list gives a clean table. If it’s not installed, you can install it with sudo apt install network-manager.

Troubleshooting

  • No wireless interface found. If ip link shows no wlan interface, your Wi-Fi adapter may be unsupported or disabled. Check with lspci | grep -i network or lsusb to see if the hardware is detected. If it is, you may need to install proprietary drivers (e.g., for some Realtek or Broadcom chips).
  • Scan returns “No scan results” or empty. This can happen if the interface is down, the driver doesn’t support scanning, or you’re in an area with no networks. Bring the interface up, move closer to a router, or try sudo iwlist wlan0 scan.
  • “Operation not permitted” error. This usually means you need sudo. If sudo doesn’t help, the interface may be in a bad state. Try sudo ip link set wlan0 down then up again.
  • Command not found. Install the missing package: sudo apt install iw or wireless-tools. If you’re offline, you may need to download the .deb files on another machine and transfer them.
  • Scan works but no SSIDs appear. Some networks hide their SSID. You’ll see a blank SSID or “” in the output. You can still connect if you know the name.
  • Signal is weak even close to router. Check if the antenna is connected (if external). Also, some USB adapters are low-power; consider using a powered USB hub.

Frequently Asked Questions

Do I need to be root to scan Wi-Fi?

Yes, on most systems scanning requires root privileges. Use sudo with the scan commands. Some distributions allow unprivileged scans if the interface is set to allow it, but that’s not the default on Ubuntu Server.

Why does my scan show no networks even though my phone sees them?

Your Wi-Fi adapter might not support the band (e.g., only 2.4 GHz while the router broadcasts 5 GHz), or the driver may not support scanning. Also, ensure the interface is up. Try sudo iwlist wlan0 scan and check for errors.

What is the difference between iw and iwlist?

iw is the modern replacement for iwconfig and iwlist. It uses the nl80211 interface and provides more detailed information. iwlist is older but still works on many systems. Both are fine for scanning.

Can I scan for Wi-Fi without installing anything?

If your system has NetworkManager installed, you can use nmcli dev wifi list without any extra packages. Otherwise, you need iw or wireless-tools, which you can install with apt.

How do I connect to a Wi-Fi network from the command line?

After scanning, you can connect using nmcli (if NetworkManager is present) or by configuring wpa_supplicant. For example: nmcli dev wifi connect "SSID" password "pass". For wpa_supplicant, you’d create a config file and run it.

What does the signal strength number mean?

It’s in dBm, a logarithmic measure. Values closer to 0 are stronger. Typically, -50 dBm is excellent, -67 dBm is good, -70 dBm is marginal, and -80 dBm is very weak. Anything below -80 dBm may be unusable.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →