This post will guide you how to run sudo command without entering a password in your Linux operating system. How do I execute sudo command without a password for a user or group only in Linux system.
- Sudo Command
- Executing All Sudo Command without Password For a User
- Executing All Sudo Command Without Password For a Group
- Executing Specific Sudo Command without Password
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. The invoking user’s real (not effective) user ID is used to determine the user name with which to query the security policy.
sudo supports a plugin architecture for security policies and input/output logging. Third parties can develop and distribute their own policy and I/O logging plugins to work seamlessly with the sudo front end. The default security policy is sudoers, which is configured via the file
/etc/sudoers, or via LDAP. See the Plugins section for more information.
To execute sudo command without password in your Linux system, and you need to edit its configuration file called
/etc/sudoers using visudo command. Before modifing it, you’d better backup this file. just do the following steps:
/etc/sudoers file with the following command:
$ sudo cp /etc/sudoers /etc/sudoers.bak
#2 type the following command to edit the
$ sudo visudo
#3 you need to append the folliwng line into the file so that to run all sudo command without a password for a paritcular user named “
devops ALL=(ALL) NOPASSWD:ALL
#4 save and close the file. you can try to install a pacakge to check if executing sudo command would not be asked to enter a password.
[devops@mydevops ~]$ sudo yum install firefox Last metadata expiration check: 0:36:05 ago on Sun 06 Oct 2019 04:59:28 AM EDT. Package firefox-60.5.1-1.el8.x86_64 is already installed. Dependencies resolved. ====================================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================================== Upgrading: firefox x86_64 60.8.0-1.el8_0 AppStream 93 M Transaction Summary ====================================================================================================================================================================== Upgrade 1 Package Total download size: 93 M Is this ok [y/N]:
If you want to execute all sudo command without password for a paritcular group named “
devops‘ only, and you can append the following line into the
/etc/sudoers file in the above step3.
%devops ALL=(ALL) NOPASSWD: ALL
If you only want to permit a user or group to run a given command(
reboot) using sudo command with a password, and you need to append the following line into the
devops ALL=(ALL) NOPASSWD: reboot %devops ALL=(ALL) NOPASSWD: reboot
You should know that how to run sudo command without a password for a user or group in your CentOS or RHEL or Ubuntu Linux system.