Ubuntu, CentOS and MacOS set sudo without entering password

It needs to be configured in /etc/sudoers. The permission of this file is r/r/n, and you need to add write permission before configuration.

sudo chmod u+w /etc/sudoers

Examples of password-free configurations can be found

%wheel ALL=(ALL) NOPASSWD: ALL

% should refer to the group, there is no authentication, I directly wrote my own username.

Since the original permission is r/r/, it is best to change it back after modification.

sudo chmod u-w /etc/sudoers
Experiments have proved that each line of configuration in the sudoers file does not take effect at the same time, but takes effect line by line. The final result of the multi-line configuration of the same object is based on the final running result. Therefore, if a user is configured to be password-free in the front, and the group to which the user belongs cannot be configured to be password-free later, then the user is ultimately different from password-free. It is recommended to put personal configuration at the end of the sudoers file, not next to the template in the comments.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326605974&siteId=291194637