I'm running Ubuntu 13.10 on a late 2013 Macbook Pro Retina (booted via Refind).

My issue is that running iwconfig doesn't output Link Quality or Signal Level unless run as sudo.

me:~$ sudo iwconfig
eth0      IEEE 802.11abg  ESSID:"redacted_essid"  
          Mode:Managed  Frequency:2.447 GHz  Access Point: RE:DA:CT:ED:XX:XX   
          Bit Rate=144 Mb/s   Tx-Power=200 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=70/70  Signal level=-35 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

lo        no wireless extensions.

Not as sudo:

me:~$ iwconfig  
eth0      IEEE 802.11abg  ESSID:"redacted_essid"  
          Mode:Managed  Frequency:2.447 GHz  Access Point: RE:DA:CT:ED:XX:XX   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

lo        no wireless extensions.

Is this normal, and is there something I can do to make it work without super user permissions?

My reason is that the Vicious Wifi Widget for Awesome Window Manager expects to be able to query iwconfig for this information not as root: http://git.sysphere.org/vicious/tree/widgets/wifi.lua

Thanks so much.

  • Running a 14.04 alpha system the output from sudo iwconfig and iwconfig is different, but Link Quality and Signal level are in either output. It would be interesting to boot a live-CD for 14.04 to see if this works there, as it may be card specific. Cirtainly this information does not seem particularly sensitive and is exposed for me on iwlwifi. – Andy Feb 4 '14 at 14:00

The command iwconfig is a system administration commands (usually only for root). See man iwconfig. It is documented under section 8 of manpages. To know more about manpages see this post.

If you try in terminal,

$ type iwconfig 
iwconfig is hashed (/sbin/iwconfig)

and /sbin contains privileged executables. This is the reason why you are not able to have its full features when using as non-root user. There is nothing abnormal.

How to use sudo iwconfig without password [source]

You can use the NOPASSWD directive in your /etc/sudoers file.

If your user is called user and your host is called host you could add these lines to /etc/sudoers:

user host = (root) NOPASSWD: /sbin/iwconfig

This will allow the user user to run the command sudo iwconfig on host without entering a password. All other sudoed commands will still require a password.

It is recommended to use sudo visudo to edit the file. Read this nice post before you proceed. There you can find an alternative too if you do not wish to modify your /etc/sudoers

The other bad way [not recommended] is to ask sudo to read your password from a file where  your password is already stored. But this may be severe security concerns. -S switch enables sudo to read a password from standard input.

If you store your password in a file mypsd.txt that contains only your password followed by a new line character. Then the following command will run reading your password from that file,

cat /path/to/mypsd.txt | sudo -S iwconfig
  • Excellent answer - thank you. I have added myusername myhostname = (root) NOPASSWD: /sbin/iwconfig to /etc/sudoers.d/iwconfig, but that doesn't seem to have worked. Some more info: -r--r----- 1 root root 46 Jan 31 11:52 /etc/sudoers.d/iwconfig. Any clues? – doctororange Jan 31 '14 at 1:04
  • Ah, I didn't realise that the NOPASSWD tag still requires you to prepend sudo to the command. – doctororange Jan 31 '14 at 2:27
  • Hope everything is ok now. Feel free to discuss if you have any query. – souravc Jan 31 '14 at 3:14
  • I suspect I may need to use (ALL) instead of (root), or something similar. Essentially I need to be able to get the full iwconfig output without prepending sudo to the command, since that's what the wifi.lua script linked in the OP executes. – doctororange Jan 31 '14 at 4:03
  • can't say at this moment (I am not near a ubuntu system), I need to check it. But there is no harm to use sudo inside a script. use sudo iwconfig it will be executed without any problem, I think. – souravc Jan 31 '14 at 4:42

Yet Another Simple Solution

The default file permissions of iwconfig in Xubuntu 13.10 are:

$ ls -l /sbin/iwconfig
-rwxr-xr-x 1 root root 26152 Feb  03  2014 /sbin/iwconfig

Following commands might fix it in other Ubuntu versions:

$ sudo useradd -G sudo <your user name>
$ sudo chmod 755 /sbin/iwconfig

-- Regards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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