2

This question already has an answer here:

I wanted to follow this guide to avoid typing a password every time I want to use "sudo iwconfig" command

http://ubuntuforums.org/showthread.php?t=1132821

I tried the steps with "apt-get" command and it worked

sudo select-editor
sudo visudo
add %admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get to the bottom line

but they didn't work with "iwconfig"

I believe the reason behind that is "iwconfig" source files are not stored in "/usr/bin/" directory because ls /usr/bin/ | less doesn't show anything named iwconfig

So, what is the directory I should enter before iwconfig?

Thanks in advance

marked as duplicate by Braiam, karel, user117103, falconer, Eric Carvalho Feb 9 '14 at 0:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

Running iwconfig without password

Create a file called iwconfig in /etc/sudoers.d/:

$ sudo visudo -f /etc/sudoers.d/iwconfig

Add the following:

your-user-name ALL=(root) NOPASSWD: /sbin/iwconfig

Check if the file has the right permissions:

$ ls -l /etc/sudoers.d/iwconfig

Should be:

-r--r----- 1 root root 0 Feb 1 21:34 /etc/sudoers.d/iwconfig

If not:

$ pkexec chown root:root /etc/sudoers.d/iwconfig
$ pkexec chmod 0440 /etc/sudoers.d/iwconfig

If you cannot open the iwconfig file, try:

pkexec visudo -f /etc/sudoers.d/iwconfig

-- Regards

@see:

  • Created the file, checked the permissions and they were fine but iwconfig still asks for the password – loo3y35 Feb 2 '14 at 13:49
  • Have you tried sudo -u root iwconfig? This should not bring up a password prompt. Additionally sudo -l should display: (root) NOPASSWD: /sbin/iwconfig – suqed Feb 2 '14 at 20:22
  • To shorten it type nano ~/.bashrc and add alias iwconfig="sudo iwconfig" at the end of the file. – suqed Feb 2 '14 at 20:31
  • Missed source ~/.bashrc. – suqed Feb 2 '14 at 20:38
  • I actually could get it to work using the other answer but thank you for the replies :) – loo3y35 Feb 2 '14 at 21:43
0

I could solve the problem using the following

sudo visudo

adding %admin ALL=(ALL)NOPASSWD:/sbin/iwconfig to the bottom line

  • be careful with %admin since everyone in the admin group can do this. – Braiam Feb 2 '14 at 17:44

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