- How to install sudo on Debian or Ubuntu Linux
- Command to Install sudo on Debian Linux Minimal server
- 1. Apt update cache
- 2. Command to install sudo on Debian or Ubuntu server
- 3. Create a new user
- 4. Add a new user to the sudo group in Debian
- 5. Switch to new user
- 2 thoughts on “How to install sudo on Debian or Ubuntu Linux”
- How To Install sudo on Debian 11
- What is sudo
- Install sudo Using apt-get
- Install sudo Using apt
- Install sudo Using aptitude
- How To Uninstall sudo on Debian 11
- Uninstall sudo And Its Dependencies
- Remove sudo Configurations and Data
- Remove sudo configuration, data, and all of its dependencies
- References
- Summary
- How to enable sudo on Debian 11/ 10?
- Introduction – What is sudo?
- Enable sudo on Debian 11 / 10
- 5 COMMENTS
How to install sudo on Debian or Ubuntu Linux
The command sudo, we used before other program calls to execute them. The key purpose of it is to authorize the users to run the program on behalf of and with the rights of another user to perform tasks that are reserved for administrators.
When we run the command with sudo, it asks for the password of the current user before executing the program. This checks whether the user that entered the command is the group of authorized users defined in the /etc/sudoers file or not. The target user is root assumed by default.
Under Debian, in /etc/sudoers all members of the group are sudo and allowed by default to become the user root and thus to receive root rights. The user or users created during installation belong to the group sudo by default.
In GUI desktop environments such as GNOME or KDE, root rights are sometimes automatically requested for a certain program for certain tasks by giving a graphical dialogue box. For example, you are automatically asked for your password for a program installation or upgrading system graphically, so that APT receives root rights and can install the program. In many cases, sudo no longer needs to be called manually.
Easy way to understand what sudo is for-
Command to Install sudo on Debian Linux Minimal server
Well, sudo is already in the Debian system most of the time; however, in minimal Debian installation such as Debian on Docker, the sudo will be missing. Hence, to create any other user and use that to install some software without giving root access for all the commands, we have to install sudo manually using the command line. Here are the steps to follow.
This article assumes that you already have root user access because without that we cannot install “sudo” or any other packages.
1. Apt update cache
First, run the system update command to refresh the APT repositories cache. This is necessary because many times after installing a fresh minimal Debian or Ubuntu Linux, it won’t recognize any packages to install. It is because there is no list of packages in the cache, that the system can identify to install.
2. Command to install sudo on Debian or Ubuntu server
You have the updated minimal Debian or Ubuntu server, now we can easily use the APT package manager command to install the “sudo” without the help of any additional repository as it is already available in the base repo of Debian.
3. Create a new user
Once the sudo is installed, let’s create a new user to use later with the sudo command.
adduser your-new-user
Change “your-new-user” with whatever name you want to give to your user.
For example, here we area adding a user called – h2smedia, the command will be like this:
Set password when it asks.
4. Add a new user to the sudo group in Debian
This is an important step otherwise you won’t be able to use your new user with sudo rights to install new programs.
usermod -aG sudo h2smedia
Again replace h2smedia with your user created above.
5. Switch to new user
Now, let’s switch to the newly created user from root to run a non-root user but with sudo rights.
su your-new-user
Run sudo commands, to test it:
Enter the password you have created for your user.
Now to log back again to the root user, you can simply type:
In this way, anybody who has the root user rights can install and add a new user with sudo rights. However, make sure you are using a strong password.
Other Articles:
2 thoughts on “How to install sudo on Debian or Ubuntu Linux”
I have Ubuntu 18.04 but cannot do the following install:
/home/fred/Downloads/hotspot shield)f=hotspotshield_1.0.7_amd64.deb /home/fred/Downloads/hotspot shield)sudo apt install ./$f
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘hotspotshield:amd64’ instead of ‘./hotspotshield_1.0.7_amd64.deb’
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation: The following packages have unmet dependencies:
hotspotshield:amd64 : Depends: libdbus-1-3:amd64 (>= 1.10) but it is not installable
Depends: libnl-3-200:amd64 (>= 3.2.0) but it is not installable
Depends: libnl-route-3-200:amd64 (>= 3.2.0) but it is not installable
Depends: network-manager:amd64 (>= 1.10) but it is not installable
E: Unable to correct problems, you have held broken packages. How can I fix this? Reply
How To Install sudo on Debian 11
In this tutorial we learn how to install sudo on Debian 11.
What is sudo
Sudo is a program designed to allow a sysadmin to give limited root privileges to users and log root activity. The basic philosophy is to give as few privileges as possible but still allow people to get their work done. . This version is built with minimal shared library dependencies, use the sudo-ldap package instead if you need LDAP support for sudoers.
There are three ways to install sudo on Debian 11. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.
Install sudo Using apt-get
Update apt database with apt-get using the following command.
After updating apt database, We can install sudo using apt-get by running the following command:
sudo apt-get -y install sudo
Install sudo Using apt
Update apt database with apt using the following command.
After updating apt database, We can install sudo using apt by running the following command:
Install sudo Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.
After updating apt database, We can install sudo using aptitude by running the following command:
sudo aptitude -y install sudo
How To Uninstall sudo on Debian 11
To uninstall only the sudo package we can use the following command:
Uninstall sudo And Its Dependencies
To uninstall sudo and its dependencies that are no longer needed by Debian 11, we can use the command below:
sudo apt-get -y autoremove sudo
Remove sudo Configurations and Data
To remove sudo configuration and data from Debian 11 we can use the following command:
Remove sudo configuration, data, and all of its dependencies
We can use the following command to remove sudo configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge sudo
References
Summary
In this tutorial we learn how to install sudo on Debian 11 using different package management tools like apt, apt-get and aptitude.
How to enable sudo on Debian 11/ 10?
Debian 11 has come out of the oven. It is great news for all users of this great Linux distribution. However, it is also great for all of us who use Linux. If like me, you have just installed it, you will notice that your regular user cannot use sudo . And if you come from using Ubuntu or Linux Mint, then surely you miss it. So this post will show you how to enable sudo on Debian 11 /10.
Introduction – What is sudo?
In a PC that runs some Linux distribution, there are different users. Each of them has defined roles and permits. For example, to install a package in Debian it is necessary to do it with root user privileges. Then, not all users can do all things.
The sudo program is part of the GNU suite. It is a small application that allows the execution of commands with the security privileges of another user. Normally, this “other” user is root.
By Debian security policy, this program is not enabled for your regular user. And the truth is that if you use Debian on your personal computer we can enable it and it would not be a problem. However, if you install Debian to be used on a server, you should not do it.
In any case, sudo allows you to execute commands that your user can not. In addition, the commands that are applied with sudo are not registered in the system log.
Enable sudo on Debian 11 / 10
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.
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.
Sudo is quite light so the installation is quite fast.
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.
Under it, add your user and leave the rest the same. Something like that.
Next, press CTRL + O to save the changes and CTRL +X to close it.
After that, you can use sudo.
So, share this post with your friends and join our Telegram Channel.
5 COMMENTS
Thank you …this was the only working tutorial i found in the web …a big shame on debian forums because they making bashing against each other …but no useful information.
it seems Debian is on a wrong way…they like to be like ubuntu or some other “userfriedly” distribution
now in debian buster they use clear the wrong way ….they force the user to change their habits
Before i found your tutorial i was close to remove debian 10 from the hard drive and install free bsd because its much simpler as the modern garbage in debian 10.
in a car i like to crank the window per hand ..its simple and useful …no electronics can fail and in a operating system i like also the simple and stupid methodes to administrate everything. But what should i do when they remove the god old simple things ?…throw the computer out of the window ?
sorry for my emotional comment,but i work the whole evening on this silly ..sudo problem…wastig time
and sorry for my bad english
thank you again an good bye
Well, first of all you don’t need to install and configure sudo if you actually *read* what the Debian Installer tells you. When asking to set root password it explicitly says that you can leave it blank, and then the root account will be locked, and the user you add later on will be configured to use sudo by default. Then, manually editing /etc/sudoers is not needed – just add your user to the ‘sudo’ group with:
# adduser sudo Finally, *DO NOT* edit /etc/sudoers strait with an editor! One mistake – and you may be locked out of using sudo, and if the root account is already locked, you’re screwed. Use ‘visudo’ – it checks if your edits are correct before applying them.
The problem with is it’s best practice not to do anything as root directly – so if we did elect to have a different root password, it still makes sense to configure the user in the sudoers automatically. Similar to the best practice of NOT editing important configuration files in a normal editor. You know the joke, don’t drink and root: rm -rf /