Nearly every Linux distribution these days uses the
sudo utility as a way to grant non-privileged users the ability to execute commands as privileged root users. You may have noticed that after entering your sudo password once, you can continue to execute commands without needing to re-enter it for five minutes. We can even extend this convenience by allowing any sudo commands to be executed without a password.
In this tutorial, we will cover the step by step instructions to configure a Linux system to allow the execution of
sudo commands without requiring any password. This functionality can be configured for an individual user, a group, or for everyone across the whole system. Follow along with us below to get started.
In this tutorial you will learn:
- How to allow
sudocommand without password for a user, group, or all users
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
sudopassword will make your system very insecure, especially if you choose to disable the password for all users on your system. We recommend only performing this operation on single user systems or in a test environment.
Allow Sudo Command Without Password step by step instructions
- Start by opening a command line terminal and editing the
/etc/sudoersfile. This can be accomplished with the following command:
$ sudo visudo
- Scroll down to the bottom of the file, where we will be adding a line.
- Add the following line to disable the sudo password for a specific user. In this example, we are disabling the password promot for user
linuxconfig ALL=(ALL) NOPASSWD: ALL
- Another option is to disable the sudo password for all users that belong to a certain group. For example, the
%sudoers ALL=NOPASSWD: ALL
- The last option is to disable the sudo password for every user on the system, which is the least secure and least recommended option.
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
- When done, save your changes and exit the file. The changes should take effect immediately and there is no need to restart the system. To verify it worked, open a new terminal and try executing some command with
$ sudo whoami root
In this tutorial, we saw how to allow a
sudocommand to be executed without providing an adminitrator password on a Linux system. Although it is very convenient to never be prompted for your root password, it comes with a high security risk. It is strongly discouraged to perform this operation on a shared system or production server.