5

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.

2 Answers2

6

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
sourav c.
  • 46,120
0

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.

suqed
  • 111