Last updated on October 4, 2020 by Dan Nanni
sudo
without entering a password on Linux?
sudo
allows a system administrator to grant certain users (or groups) a permission to run privileged commands on Linux system. In order to run a command with sudo
, users have to type their own password at a password prompt.
To allow a specific user to use sudo
without a password, use visudo
command to edit sudo
configuration as follows. I assume that the user name for whom you want to disable password prompt is alice
.
$ sudo visudo
alice ALL=(ALL) NOPASSWD: ALL
Ctrl-X
to leave, save your changes, and you're done. This setting will disable a password prompt for alice
when she runs any command in sudo
.
To allow a user to use sudo
without a password for specific commands only (e.g., /usr/sbin/tcpdump
and /sbin/reboot
), do the following.
$ sudo visudo
alice ALL=(ALL) NOPASSWD: /usr/sbin/tcpdump, /sbin/reboot
To allow all members of a specific group (e.g., alice_group
) to use sudo
without a password, run the following.
$ sudo visudo
%alice_group ALL=(ALL) NOPASSWD: ALL
To allow all members of a group to use sudo passwordlessly for specific commands only (e.g., /etc/init.d/apache2
), run the following.
$ sudo visudo
%alice_group ALL=(ALL) NOPASSWD: /etc/init.d/apache2
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean