I would like to see the ifconfig file with test user (under Linux Debian) that's why I have used the sudo task, but the terminal said that: test is not in the sudoers file. How can I take the test user in the sudoers file?

I've tried the /etc/pamd/su but it is not found?


The sudeoers file is usually located at /etc/sudoers.

You need administrative privileges to edit this file. Editing it directly is strongly discouraged: you could irrevocably damage your system in case of syntax errors.

The visudo tool is provided with the sudo package for safe editing. It will automatically check file's consistency before saving and abort on syntax errors.

visudo invokes the text editor set in the EDITOR environment variable, or vi otherwise. For instance, if you want to invoke Emacs instead:

$ EDITOR=emacs visudo

Once you have the editor fired up, you want to add the following line at the User privilege section:

test <host>=(ALL) /sbin/ifconfig

or, if you do not want to get prompted for a test's password

test <host>=(ALL) NOPASSWD: /sbin/ifconfig

You need to replace by your machine hostname, or 'ALL' if you want the privilege to apply on any machine.

See the man pages: sudoers(5), sudo(8) and visudo(8) for the complete documentation.

  • That's correct, but not the right solution here. Running ifconfig does not require root. – Gilles 'SO- stop being evil' Oct 22 '14 at 15:04
  • The question surprised me as well and requires clarification. – Ambrevar Oct 22 '14 at 16:46

The ifconfig command is not included in users PATH env variable. So you can either /sbin/ifconfig or modify the PATH variable to include sbin into your users path.

Add the following line to your ~/.bashrc

export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"

source ~/.bashrc using, . ~/.bashrc or source ~/.bashrc or open e new terminal which will source ~/.bashrc file automagically

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.