Debian 11 is the newly released version of the Debian Linux distribution series. Debian 11 is just like its predecessor (the Debian 10) when it comes to being an open-source operating system available to everybody for absolutely free. Debian 11, available to the world for free over the internet, is gaining massive popularity because of its support of more than 4 thousand downloadable applications. But, what’s so important about having 4 thousand downloadable applications? Well, it’s the fact that they are all available for free and are open-source.
If you are working with a Linux-based operating system, you should know that there is something called the “sudoers”. Sudoers means users with SuperUser rights. If you have no idea what that means then to put it simply, it’s the same thing as being an “administrator” on a Windows operating system, and having SU rights means to have Administrator rights of a machine.
The Sudoers can even allow other users registered on the pc to have SU rights. For example, the system administrator (which is the root-super-user) can assign any other user root right.
This way the other user (other than the system administrator) can have the sudo rights such as:
- Execute commands with root rights.
- View SU explicit files.
- Remove users from a machine.
There are two basic methods of adding a user to the Sudoers file. But, the main goal is the same, which is to go to a file called “sudoers” and edit the rights of the users mentioned in that file by using basic commands.
First Method: Add a user to Sudoers using “usermod” Command
To edit the sudoers file you must switch to the root user first:
Switch the user to the SuperUser
$ su root
After writing this command in the terminal, you’ll be checked against the credentials of the superuser, type in the root user’s credentials and you will be good to head over to the next step.
To add a specific user to the Sudo Group using “usermod” command:
The syntax of the command for adding any user to the Sudo Group is:
$ sudo usermod -aG {Group} {Username}
In this command:
- sudo: a command with root privileges
- usermod: what this does is that it changes the user’s account
- -a: to append
- G: groups(if there are any user groups)
- {Group}: the name of the group in which you want to add the user
- {Username}: the name of the user to which you want to add in Sudo Group
You are going to change the {username} with the exact name of the “user” that you want to obtain SuperUser privileges. After you have replaced it, it would look like this:
Let’s say there is no user registered on your machine other than the admin which in Linux’s case is called the SU(SuperUser), then you might want to add a user first.
To add a user the command would go like this:
$ adduser username
Go on and change the “username” to whatever you prefer.
Second Method: Add a user to Sudoers file manually
If the first method was a failure, then worry not, there is another way of achieving the same goal.
To get started with the second method, switch the user to SU just like the first step in the first method.
$ su root
It should ask for credentials, type in the credentials to continue.
Manually changing the Sudoers File
We are going to access the sudoers file, open it up, and add a few lines that would depict that a specific user has now claimed Sudo rights.
We are going to navigate to the file first with the following command:
$ sudo nano /etc/sudoers
The sudoers file will open up just like this:
Scroll all the way to the bottom of the file and type in the following line.
$ username ALL=(ALL: ALL) ALL
Just like the commands in the previous method, we are going to change the term “username” with the name of the user that is going to obtain the SU rights.
For example, we are going to give the user “itsLinuxFoss” Su rights. So, the command would be shaped like this:
$ itsLinuxFoss ALL=(ALL: ALL) ALL
The end of your Sudoers will look like this:
Time to close the file and save it. If you are not familiar with those commands on a Linux-based operating system then you are going to press Ctrl + O to save and close the file by pressing Ctrl +X
That’s it, now you can run your existing user with sudo rights on Debian 11 Bullseye and you can even use this on Debian 10 Buster.
Conclusion
Adding users to Sudoers in Debian 11 can seem like a daunting task but in reality, it is quite an easy task to achieve. Sudoers are the users that have administrative rights in a Linux-based operating system. Sudo rights are necessary for running certain commands in Linux-based operating systems. We have learned how we can add a user into the list of Sudoers using two different methods.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY