How to Add sudo on Debian 12

Super-user, commonly known as the sudo command in Debian, is used to perform different tasks as a root user. In Debian and other Linux distributions, the administrative tasks can be performed by the root users only. However, these privileges can be given to other Linux users by adding them to the sudo group by executing some simple commands. 

When the command is run with the sudo command, the password is required to proceed with its execution. When the password is entered and verified by Debian, it allows the user to run administrative commands. 

The root user can manage the access of the sudo privileges to the other users using the sudo group. The sudo command also keeps the record of the commands that are executed by the sudo users. This is the way by which the root user can monitor the activity of the sudo users on Debian. 

This post will explain the method of adding sudo on Debian Linux. Also, some other important things related to sudo will be explored with the following outline:

  1. Why Should I Use sudo instead of Root User
  2. How to Verify the User is in the sudo Group
  3. sudo: Command not found
  4. What is the Method for Adding a User to Sudoers in Debian
  5. How to Set No Password Prompt for sudo User on Debian
  6. How to Customize Credentials Cache Timeout of sudo on Debian

Let’s start the post with the understanding of sudo on Debian.

Why Should I Use sudo instead of Root User?

The sudo command allows the same privileges that can be executed by the root user. A question arises in my mind as to why there is a need to use the sudo command. The reasons for adding a user to the sudo group are:

  • The root password cannot be shared with all the users. Simply assign the users who are supposed to perform the administrative tasks in the sudo group. This will grant them the privileges of the root user for a limited period. 
  • Only when running the administrative commands then there is a need for a “sudo” command there is no need for it. This means the possibility of making mistakes while running commands can be reduced.
  • The last important reason for the sudo is that a log of the activity of the sudo users is maintained in the file and can be monitored by the root user. 

How to Verify the User is in the sudo Group?

When the new user is being created by default it is not added in the sudo group. Users can also verify whether they are in the sudo group or not by running the command:

$ groups

The output will display the group names in which the user is present. If the sudo group is there then it means the user is already present in the sudo group and can use the root user privileges. 

sudo: Command not found

Sometimes when the sudo command is being executed, an error of “sudo: command not found” is displayed on the screen. One of the major reasons for this error is that the sudo command is not being installed on the computer. The sudo command utility can be installed on Debian by using the “install” option of the apt command. 

All the reasons and their solutions are explained in the mentioned in the published post on our platform. 

What is the Method for Adding a User to Sudoers in Debian?

To add the users to “sudoers” in Debian 12, it is recommended to follow the instructions explained in the mentioned post.

How to Set No Password Prompt for sudo User on Debian?

When the sudo users try to execute the commands as the root user with the sudo, the user password is required. If you want the sudo users not to ask for the password then run the command in the root terminal:

# visudo

Add the below-mentioned line in the configuration file:


Save the file by exiting the text editor. The users will not be asked to enter the password with the sudo command. 

How to Customize Credentials Cache Timeout of sudo on Debian?

When the command is run with the sudo, it asks for the password and stores this password in cache memory for fifteen minutes by default. It means that if the command is being executed with the sudo after fifteen minutes of inactivity, the password will be required. 

To increase this time for the specific user, add the below-mentioned line in the visudo file:

Defaults:itslinuxfoss timestamp_timeout=30

The time is increased from 15 to 30 minutes. 

This is all about the usage of the sudo in Debian 12 by running simple commands.


To add the sudo on Debian 12, launch the root terminal and execute the command “visudo”. When the file is opened, add the line “username ALL=(ALL:ALL) ALL” and save the configuration file. 

This post explained the method of adding the user to the sudo group and also explored the methods to increase the cache password time on Debian 12.