password input-free for Centos user

created at 03-04-2021 views: 1

If you had an user, you can add this user to the sudoers file so that next time when you run commands like sudo ..., the OS won't ask you to input password again.

to add an user to sudoers file, we can simply access the file with:

[root@localhost ~]$ visudo

or we can first find the sudoers file:

[root@localhost ~]$ whereis sudoers

we would get:

sudoers: /etc/sudoers.rpmnew /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz

edit /etc/sudoers

[root@localhost ~]$ vim /etc/sudoers

find the following line:

root    ALL=(ALL)       ALL

locate to this line, make sure you are not in INSERT mode,

type yyp to copy this line:

root    ALL=(ALL)       ALL
root    ALL=(ALL)       ALL

now we can switch to INSERT mode and change the copied line to:

root    ALL=(ALL)       ALL
user    ALL=(ALL)       NOPASSWD:ALL

note to replece ‘user’ with your username

and then, ESC --> :wq! to save the change.

all done.

Please log in to leave a comment.