Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to get a list of all the wireless networks.

iwlist wlan0 scan | grep ESSID

This will only show me the wireless network I am currently connected to. When I run the command as root, it shows me all the available networks. If I run the command without sudo quickly after this, all the networks will show up, but after a while they are all gone except the network I am currently connected to.

Is there a way to get all the available networks when I am not root?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You could (or do?) probably use wpa_supplicant; using its ctrl_interface configuration key, you can allow non-root users (e.g. those with group wheel) access via wpa_cli (i.e. /sbin/wpa_cli scan_results [1])

# allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

There's also a command-line switch to wpa_suppliant,

-u     Enabled  DBus  control  interface. If enabled, interface defini‐
       tions may be omitted.

giving you a DBus interface and thus another possibility for non-root access (I think NetworkManager uses this interface).

[1] Once connected, this only shows the wireless LAN you are connected to...I don't know if this is any different with NetworkManager.

share|improve this answer
    
Thank you for your answer. Adding "GROUP=wheel" and calling wpa_cli scan and wpa_cli scan_results do the trick for me. Do you know if the same change (allowing the wheel group to execute) is possible with iwlist? –  Carlito Aug 14 '12 at 11:56
    
No idea, sorry. –  sr_ Aug 14 '12 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.