As a desktop system such as Ubuntu, the default login account does not have root permissions, in order to enhance the permissions to perform tasks, we generally use the sudo+ command to execute, but it is not difficult to find that we generally have to enter the password. So is there any way we can execute sudo without entering a password? Of course it is. That is to modify the sudoers file.
How do I modify sudoers? Directly modify/etc/sudoers? No, that kind of modification can easily cause a privilege disorder. When the cows are manually modified, because they are not so understanding of the format, so the editor of the error many times, so do not recommend the direct modification method. We can use Visudo to edit.
Go to the terminal, execute sudo visudo
Some rules are listed below #user Privilege specification, and what we need to do now is to do something about our users. If our user name is Nenew
On the last line of the file, add:
Nenew all= (All) Nopasswd:all
Then save exit, execute
sudo usermod-ag admin nenew
Reboot to see nenew account execution sudo still need a password? Here we need to understand the sequence of this issue, on the Ubuntu wiki has a more detailed description.
%admin all= (All)
This line only makes the Admin group users have the ability to execute commands like any account, but still need a password, so we need to add our nenew users to the admin group, so there's sudo usermod-ag admin nenew, It is then nopasswd defined, and this line must be followed by the%admin all= (all).
After the article is playing a lot of friends put forward unsafe problems, indeed, this is a security risk. The purpose of this article is also to let you understand the order of the sudoers, of course, we can put the final
Nenew all= (All) Nopasswd:all changed to restrict the command, such as canceling a password for a shutdown command
Nenew all= (All) Nopassws:/sbin/shutdown,/sbin/halt,/sbin/reboot