Linux password-free sudo settings

Linux password-free sudo settings

When we use Linux system commands, we often need root privileges, so we often use the sudo+command method, which allows your command to temporarily obtain root privileges before executing this command, but it is very troublesome to enter the password every time, here we will talk about it Here's how to perform sudo without entering a password;

Create a new file with any name in /etc/sudoer.dthe directory , such as;

sudo vi /etc/sudoers.d/test

Add the following content,

USERNAME ALL = (ALL) NOPASSWD:ALL

You need to change the above USERNAME to your current user name, and then save it. After saving, you will find that you don’t need to enter the password when you use this user to sudo later.

The following is the command line version to achieve this requirement, which can be done with one click;

sudo sh -c "echo '$USER ALL = (ALL) NOPASSWD:ALL' > /etc/sudoers.d/$USER"

Guess you like

Origin blog.csdn.net/weixin_43846408/article/details/130503798