Configure Sudo: no password for certain commands (nopasswd)

Sudo (Super User Do) is Linux console only utility allowing users to execute programs which require root rights without knowing root password. There are lots of topic why sudo rocks on the Web so here you can find a tip how to configure sudo in order to execute certain root right requiring programs without any passwords (it known as sudo nopasswd).

There are several ways to configure sudo in Linux regardless distribution you use. Its configuration file is located at /etc/sudoers and can be edited using any text editor like vi, nano, pico, gedit, mcedit whatever:

sudo vi /etc/sudoers
sudo visudo

So, in order to allow user named artemn to execute, say, ifconfig command and assign IP addresses, netmasks to interfaces, add the following line to /etc/sudoers:

artemn ALL = PASSWD: ALL, NOPASSWD: /sbin/ifconfig

Please notice if there is already line for artemn in sudoers file, just replace it with the new one.


Stefan Durand

My name is Stefan, I'm the admin of LinuxScrew. I am a full-time Linux/Unix sysadmin, a hobby Python programmer, and a part-time blogger. I post useful guides, tips, and tutorials on common Linux and Programming issues. Feel free to reach out in the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *