Sunday, May 5, 2024
837
rated 0 times [  837] [ 0]  / answers: 1 / hits: 922252  / 2 Years ago, mon, september 19, 2022, 6:39:12

Inspired by this question....



I am the sole person using my system with 12.04.

Every time I issue a sudo command; the system asks for the user password (which is good in its own way).

However I was thinking; without activating the root account; how can I execute the sudo commands which will not ask for user password to authenticate.



NOTE: I want to execute sudo command without authenticating via password; only when they are executed via terminal.

I don't want to remove this extra layer of security from other functions such a while using 'Ubuntu software center' or executing a bash script by drag-drop something.sh file to the terminal.


More From » command-line

 Answers
3

You can configure sudo to never ask for your password.



Open a Terminal window and type:



sudo visudo


In the bottom of the file, add the following line:



$USER ALL=(ALL) NOPASSWD: ALL


Where $USER is your username on your system.
Save and close the sudoers file (if you haven't changed your default terminal editor (you'll know if you have), press Ctl + x to exit nano and it'll prompt you to save).



As of Ubuntu 19.04, the file should now look something like



#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

YOUR_USERNAME_HERE ALL=(ALL) NOPASSWD: ALL


After this you can type sudo <whatever you want> in a Terminal window without being prompted for the password.



This only applies, to using the sudo command in the terminal. You'll still be prompted for your password if you (for example) try to install a package from the software center



gui password prompt


[#37821] Tuesday, September 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rtbrbab

Total Points: 461
Total Questions: 126
Total Answers: 117

Location: Saudi Arabia
Member since Fri, Jul 1, 2022
2 Years ago
;