How to use sudo without password in Linux

Note : This article will see how to disable sudo password in latest Ubuntu release. Process details may differ in other distributions.

Edit file sudoers

To disable password checking when using sudo for your account, you must edit the 'sudoers' file. This is where the access to the sudo command is specified for each user account or user group. However, it's best not to try to edit the file directly. Instead, run your favorite Terminal and type:

sudo visudo

Turn off sudo password for your account

To prevent sudo from asking you for a password, first check if there are any existing rules with your alias. If so, please change it as shown in the section below. If not, go to the end of the file and create a new rule there. It should look like this:

USERNAME ALL=(ALL) NOPASSWD:ALL

For the alias in the example, this rule is:

ducklord ALL=(ALL) NOPASSWD:ALL

How to use sudo without password in Linux Picture 1

Save your changes and exit the editor. Since the installation examples, the nano editor, writer should have used Ctrl + O , followed by Ctrl + X .

Use sudo without password

That's all you have to do. From now on, sudo will no longer ask for your password. Test it with a command like sudo apt update or by installing an application with sudo apt install as test, for example:

sudo apt install links

How to use sudo without password in Linux Picture 2

Don't turn off sudo passwords for everyone!

If you are sharing your computer with others and want to help them out with the hassle of having to enter a password whenever they use sudo, don't do so. Actually, there should be only one primary user with sudo privileges.

Sudo is no longer considered as a security measure against users with local access to hardware. It's not difficult to reset root password if you have local access to a Linux installation. Instead, it's there for the same reasons Windows annoying User Account Control, acting as an ultimate layer of protection between users, computers, and potential chaos, because a wrong command could This results in deletion of all data, destruction of settings or unintended sharing of personal information.

Disabling a sudo password is only good for those who have a good experience with the Linux command line and are the only user on their computer.

It should be emphasized that this will remove this last protective barrier between users and their own bugs. The article strongly recommends that you also back up your entire system and all data before doing so.

  1. How to check sudo history in Linux
  1. How to reset password for sudo in Debian
  2. Linux SUDO error allows to run commands as root
  3. 20+ essential Linux security commands
  4. The basic Linux commands everyone needs to know
4.1 ★ | 104 Vote

May be interested

  • How to fix 'No Installation Candidate' error in UbuntuPhoto of How to fix 'No Installation Candidate' error in Ubuntu
    have you tried to install something, but ubuntu can't handle it? apt mentions something related to no installation candidate what does this mean, where does the source of the problem come from, and is it fixable?
  • How to enable Dark Mode in Ubuntu 20.04 LTSPhoto of How to enable Dark Mode in Ubuntu 20.04 LTS
    if you have ever used dark mode on a mobile phone, then you will be surprised to learn that it is also available on linux computers. in this tutorial, tipsmake.com will show you how to enable dark mode on a full ubuntu linux system.
  • How to install Hyper Terminal in Ubuntu 20.04Photo of How to install Hyper Terminal in Ubuntu 20.04
    hyper is an open source application supported on all three major platforms: windows, linux, and macos. in this tutorial, tipsmake.com will explain how to install hyper terminal in ubuntu system.
  • How to use the history command in LinuxPhoto of How to use the history command in Linux
    as you spend more and more time in terminal sessions, you will constantly find new commands that make everyday tasks more efficient. the gnu history command is one of them.
  • How to set up Bluetooth in LinuxPhoto of How to set up Bluetooth in Linux
    other distributions like fedora and arch linux require you to do some setup before you can fully enjoy the benefits of bluetooth on your computer. here is how you can set up bluetooth in linux.
  • How to install Putty SSH Client on Ubuntu 20.04 LTSPhoto of How to install Putty SSH Client on Ubuntu 20.04 LTS
    in this article, tipsmake.com will explain how to install putty on ubuntu 20.04 lts system. the same process can be used for debian, mint and earlier ubuntu releases.