How to Enable sudo Command in Debian 10/11/12

By default, if you set a root password during your Debian installation, the sudo command is not installed and enabled. In such a situation, an administrative user who tries to use the sudo command will encounter the "-bash: sudo: command not found" error.

This guide will walk you through installing the sudo command in Debian 10/11/12. It also demonstrates how to enable a user account in Debian to use sudo. This is also a solution to resolve the "sudo command not found" error in Debian.

You should also read: Difference Between sudo and su Commands in Linux

Install sudo Command in Debian

Begin by logging into your Debian system using either the graphical user interface (GUI) or ssh. Then launch a fresh terminal window. You can then use the su command switch to the root account. When prompted, enter your root password. And install the sudo command using the apt package manager as shown:

$ su
# apt-get install sudo
Switch to the root account and install the sudo command

Alternatively, log into the root account, open a terminal window, and issue the following command:

# apt-get install sudo
Add User to sudo Group

After installing the sudo command as shown above, add the user you want to use the sudo command to the sudo system group. Remember to change fossman to your username:

# adduser fossman  sudo
# usermod -aG sudo fossman
Verifying sudo Setup

Now, log out and then log back in as the user fossman. To verify that the user fossman is now in the sudo group, run the groups command in the terminal.

$ groups
Check users groups in Linux

Once you have confirmed that the user fossman is in the sudo group, test if the user can invoke the sudo command. Run the following command to ensure that the user fossman has permission to execute other commands with sudo. You will be prompted to enter your account password to proceed:

$ sudo apt-get update
Test sudo usage

In this article, I demonstrated how to install the sudo command in Debian to resolve the sudo command not found error and enable a user account to utilize sudo. Please use the feedback form below if you have any comments.

Reference guide:

Spread the love

You may also like...

1 Response

  1. Andrew Hill says:

    I been though the stages shown above but still I cannot use the sudo command

Leave a Reply

Your email address will not be published. Required fields are marked *