Scanning for wifi networks will show you the ssids of all the wifi networks in your neighbourhood that your wifi adapter can detect or connect to. By default the gui network manager apps do this in kde and gnome desktop environments.
However you can also scan the wifi networks from the command prompt. In this article we take a look at some simple commands that can be used to list out all the wifi networks that can be seen by the wifi adapter.
The iwlist command when run with root privileges can scan and list out the wifi networks. Using grep we can extract the specific piece of information we are interested in. Here is a minimal example:
$ sudo iwlist wlp0s20f3 scan | grep -i 'frequency\|ssid\|signal' Frequency:2.442 GHz (Channel 7) Quality=36/70 Signal level=-74 dBm ESSID:"AirtelFiber" Frequency:2.412 GHz (Channel 1) Quality=43/70 Signal level=-67 dBm ESSID:"TP-Link_6018" Frequency:2.422 GHz (Channel 3) Quality=33/70 Signal level=-77 dBm ESSID:"Himadri" Frequency:2.432 GHz (Channel 5) Quality=31/70 Signal level=-79 dBm ESSID:"dlink-15A3" Frequency:2.437 GHz (Channel 6) Quality=30/70 Signal level=-80 dBm ESSID:"OnePlus 5" Frequency:2.447 GHz (Channel 8) Quality=33/70 Signal level=-77 dBm ESSID:"Krishna" Frequency:2.457 GHz (Channel 10) Quality=29/70 Signal level=-81 dBm ESSID:"JioFiber-01" Frequency:2.462 GHz (Channel 11) Quality=25/70 Signal level=-85 dBm ESSID:"Ayush22" Frequency:5.18 GHz (Channel 36) Quality=22/70 Signal level=-88 dBm ESSID:"Ayush22_5G" Frequency:5.22 GHz (Channel 44) Quality=24/70 Signal level=-86 dBm ESSID:"Himadri_5G" Frequency:2.417 GHz (Channel 2) Quality=33/70 Signal level=-77 dBm ESSID:"deep wifi" Frequency:2.452 GHz (Channel 9) Quality=23/70 Signal level=-87 dBm ESSID:"Subash_ext" Frequency:2.462 GHz (Channel 11) Quality=22/70 Signal level=-88 dBm ESSID:"angshu" Frequency:5.745 GHz Quality=26/70 Signal level=-84 dBm ESSID:"AirtelFiber_5GHz" $
You need to specify the interface name of your wifi adapter. If you don't already know that use the iwconfig command to find it.
Note that it is important to run the command with root privileges. Without root the command will run but the output will not be accurate and keep changing everytime.
We can see the ssid, signal level, frequency band and channel number of each wifi network. This is useful information!
2. iw command
The next command is iw and it can scan the wifi networks as well.
$ sudo iw dev wlp0s20f3 scan | grep -i 'ssid\|signal\|^bss' BSS 98:35:ed:d4:e1:48(on wlp0s20f3) -- associated signal: -66.00 dBm SSID: AirtelFiber BSS ac:84:c6:f4:60:18(on wlp0s20f3) signal: -62.00 dBm SSID: TP-Link_6018 BSS b6:a7:c6:53:cf:00(on wlp0s20f3) signal: -79.00 dBm SSID: BSS b4:a7:c6:53:cf:00(on wlp0s20f3) signal: -80.00 dBm SSID: Himadri HESSID: 00:00:00:00:00:00 BSS b4:b0:24:3f:29:44(on wlp0s20f3) signal: -79.00 dBm SSID: deep wifi BSS 8c:a3:99:d3:79:f3(on wlp0s20f3) signal: -83.00 dBm SSID: JioFiber-01 BSS 98:35:ed:d4:e1:4c(on wlp0s20f3) signal: -82.00 dBm SSID: AirtelFiber_5GHz BSS b4:a7:c6:53:cf:01(on wlp0s20f3) signal: -85.00 dBm SSID: Himadri_5G BSS b6:a7:c6:53:cf:01(on wlp0s20f3) signal: -84.00 dBm SSID: BSS 8c:a3:99:2f:a9:fd(on wlp0s20f3) signal: -84.00 dBm SSID: Ayush22_5G BSS 0c:80:63:76:5f:90(on wlp0s20f3) signal: -79.00 dBm SSID: Krishna BSS 7a:22:e5:f1:83:6d(on wlp0s20f3) signal: -83.00 dBm SSID: OnePlus 5 $
The output has lots of information quite similar to the iwlist command.
3. nmcli command
The nmcli command is actually a tool to control NetworkManager from the terminal. And it can used to query the interface for available wifi networks. Here is a quick example.
Note that we need not provide the interface name of the wifi adapter with nmcli.
$ nmcli dev wifi list IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY AC:84:C6:F4:60:18 TP-Link_6018 Infra 1 270 Mbit/s 64 ▂▄▆_ WPA2 * 98:35:ED:D4:E1:48 AirtelFiber Infra 7 130 Mbit/s 53 ▂▄__ WPA2 B4:B0:24:3F:29:44 deep wifi Infra 2 270 Mbit/s 39 ▂▄__ WPA2 B4:A7:C6:53:CF:00 Himadri Infra 3 130 Mbit/s 39 ▂▄__ WPA2 60:63:4C:84:15:AA dlink-15A3 Infra 5 270 Mbit/s 35 ▂▄__ WPA1 WPA2 8C:A3:99:D3:79:F3 JioFiber-01 Infra 10 130 Mbit/s 34 ▂▄__ WPA2 0C:80:63:76:5F:90 Krishna Infra 8 405 Mbit/s 32 ▂▄__ WPA2 8C:A3:99:2F:A9:FC Ayush22 Infra 11 130 Mbit/s 29 ▂___ WPA2 8A:D8:1B:26:FC:02 -- Infra 9 195 Mbit/s 27 ▂___ WPA2 8C:A3:99:2F:A9:FD Ayush22_5G Infra 36 270 Mbit/s 27 ▂___ WPA2 B6:A7:C6:53:CF:01 -- Infra 44 270 Mbit/s 27 ▂___ WPA2 98:35:ED:D4:E1:4C AirtelFiber_5GHz Infra 149 270 Mbit/s 27 ▂___ WPA2 10:62:EB:1D:D2:F5 Debnath_Adv2 Infra 1 270 Mbit/s 25 ▂___ WPA1 WPA2 7A:22:E5:F1:83:6D OnePlus 5 Infra 6 130 Mbit/s 25 ▂___ WPA2 B4:A7:C6:53:CF:01 Himadri_5G Infra 44 270 Mbit/s 24 ▂___ WPA2 84:D8:1B:26:FC:02 Subash_ext Infra 9 195 Mbit/s 22 ▂___ WPA1 WPA2 84:D8:1B:14:9F:D0 Joydip Infra 10 270 Mbit/s 22 ▂___ WPA2 60:E3:27:7B:2B:D4 angshu Infra 11 135 Mbit/s 20 ▂___ WPA2 $
The nmcli command generates a fancy colorful output with a nice looking signal strength bar graph. The output is quite well formatted also.
That was a quick list of commands to query wifi networks from the command shell. If you want to learn more about wifi commands in linux check out our previous articles.
Top 3 Commands to check Wifi Information on Ubuntu / Linux - iwconfig, iwlist, nmcli
How to check what Wifi Standard is being used in Linux
How to check supported Wifi Standards on Linux
How to check USB Wifi Adapter details on Linux - iw, lsusb, iwlist, iwconfig