In Unix world, we shouldn’t use administrator user without some important stuff
which needs access to it. There is a utility sudo we can use to have
administrator access. But everytime you invoke it, it asks for your user’s
password.
Today, I’m going to guide you, how you can use sudo without password.
Once you install Debian, you get some option to create a user. And if you
choose the option, “Don’t use root for login”, this new user becomes privileged
user by default. Which means you can invoke any command by using sudo. It will
ask for your password and command is executed.
Assuming you have a privileged user, edit sudoers file.
On my Debian installation, it looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
## /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
|
At the end of the file, just append this:
1
|
username ALL=(ALL) NOPASSWD:ALL
|
Replace username with your username.
Here is my sudoers file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
# I don't want a password everytime for my user.
ak ALL=(ALL) NOPASSWD:ALL
#includedir /etc/sudoers.d
|
Now open a new terminal and try to install something using sudo. You won’t be
asked to enter your password from now.