Depending on how you installed Debian 11 / 10, sudo may not have been installed by default. This is normal, actually. So first you have to install it and for that, you need to have access to the root user of the system. This is vital. Typically the Live ISO's already come with sudo installed and this is not required.
There are many ways of adding sudo, this is just the way that works for me. If you have another way of adding sudo, I encourage you to post it below.
So, open a terminal or connect to your server using SSH..
Then, you will have to enter the root user key. If you did the installation, there should be no problem. After that, you can install sudo from the Debian repositories. Many install tutorials forget this step.
Now you have to modify the file /etc/sudoers which is where all the sudo configuration is located. You can use the nano editor for this.
The file does not have too many lines. In the user privilege specification section, you will find a line like this:
Add your username and the rest of the ALL= as shown in the image below:

There are many ways of adding sudo, this is just the way that works for me. If you have another way of adding sudo, I encourage you to post it below.
So, open a terminal or connect to your server using SSH..
Code:
su
Code:
su root
Then, you will have to enter the root user key. If you did the installation, there should be no problem. After that, you can install sudo from the Debian repositories. Many install tutorials forget this step.
Code:
apt install sudo
Now you have to modify the file /etc/sudoers which is where all the sudo configuration is located. You can use the nano editor for this.
Code:
sudo nano /etc/sudoers
The file does not have too many lines. In the user privilege specification section, you will find a line like this:
Code:
root ALL=(ALL:ALL) ALL
Add your username and the rest of the ALL= as shown in the image below:

Last edited: