If you’re the only one using your Linux computer, why have it continuously nag you for your password? Let’s see how you can use sudo without having to type a password each time.
Note: we’ll see how to disable the sudo password in the latest version of Ubuntu. Details of the process may be different in other distributions.
Edit Sudoers File
To disable password checks when using sudo for your account, you must edit the “sudoers” file. It’s where access rights to the
sudo command are defined for individual user accounts or user groups. It would be best if you didn’t try to edit the file directly, though. Instead, run your favorite terminal and enter:
Disable Sudo Password for Your Account
To stop sudo from asking you for your password, first, check whether there’s an existing rule with your alias. If there is, change it to what we’ll see next. If there isn’t, move to the end of the file and create a new rule there. It should look like:
USERNAME ALL=(ALL) NOPASSWD:ALL
For my alias, this rule was:
ducklord ALL=(ALL) NOPASSWD:ALL
Save the changes and exit the editor. Since in our installation the editor was nano, we used Ctrl + O, followed by Ctrl + X.
Use Sudo without Password
That is all you have to do – from now on, sudo won’t ask for your password anymore, provided everything went according to plan and no typo thwarted our plans. Check it out with a command like
sudo apt update, or by installing an app with
sudo apt install as a test, for example:
sudo apt install links
Don’t Disable Sudo Passwords for Everyone
If you’re sharing your computer with others, and you want to save them the hassle of also having to enter their password whenever they use sudo – don’t. In fact, there should only be one main user that has sudo privilege.
Sudo isn’t regarded anymore as a security measure against users with local access to our hardware. It’s not that hard to reset the root password if you have local access to a Linux installation. Instead, it’s there for the same reason as Windows’s annoying User Account Control: as a last protective layer between us, our computer, and potential chaos. And that’s because one wrong command can lead to the deletion of all our data, the destruction of our installation, or the unintended sharing of personal information.
Disabling the 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.
We must stress that this removes this last protective barrier between a user and their own mistakes. We heavily suggest you also make a full backup of your system and all its data before doing that.
Our latest tutorials delivered straight to your inbox