$ whoami
Remeber this for later.
$ sudo visudo # This is a special command which edits that file.
Type your password if it prompts you. This will be the last time you have to.
Depending on your $EDITOR
ENV variable, either vi or nano should have brought up /etc/sudoers
.
Find this area of the file:
# root and users in group wheel can run anything on any machine as any user
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
Add a line after it (below). Rreplace <USERNAME>
with your username you got from whoami
:
# root and users in group wheel can run anything on any machine as any user
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
<USERNAME> ALL = (ALL) NOPASSWD: ALL
Write the file and exit.
<ESC>:wq<ENTER>
<Ctrl-O><ENTER>(For the confirmation)<Ctrl-X>
You should never be prompted for a sudo password again.
You should never edit /etc/sudoers
manually since you may (among other things) inadvertantly cause the file permissions to change. This renders sudo
unusable and you will not be able to change the permissions back.
In the vast majority of cases, the security impact is negligible. See this write up if you want to know why.