Advance

Tutorial Setup Sudo Privileges For User In Ubuntu 20.10

Tutorial Setup Sudo Privileges For User In Ubuntu 20.10 Server
0
(0)

Tutorial Setup Sudo Privileges For User In Ubuntu 20.10 Server.  Due to standard definitions, sudo is a program for the Unix-like computer operating system that allows users to run programs with the security privileges of another user. Buy a Linux VPS to have a real experience with this guide.

Tutorial Setup Sudo Privileges For User In Ubuntu 20.10 Server

As an administrator, you need to run your applications in Linux. You can choose two ways to do this. First, is to switch to the superuser which is also called root and the su command will be used if you use this solution. The second way is to take advantage of sudo. due to what distribution you use, you should decide which way is more suitable. For example, if you are using Fedora, Red Hat, or openSuSE, they enable the root user but others like Ubuntu and Debian do not. However, sudo is important to many Linux distributions as it allows a user to run a program as another user. Sometimes it not depend on what distribution you are currently using, there will come a time when you will have to take advantage of sudo.

How do I Setup Sudo Privileges For User In Ubuntu 20.10 Server

What Is The Difference Between sudo And su

If you are used to working with a traditional Linux setup, you may use su command to gain root privileges to log in as the root. But it is recommended to not log in as the root user. Every time you use a distribution that relies on su and allows the root user login, login as your standard user, and su to the root user. But with sudo-based distributions, you can not log in as a root user. In some distributions like Ubuntu, the root user account is “disabled” and you see that standard user accounts are restricted from performing sensitive tasks, such as viewing the contents of the /root directory. So, you can not log in as root and you can not su to become the root user. So, users need the help of sudo to gain administrative privileges to do this issue. Additionally, you will use sudo command as the preferred means to handle elevated permissions. Using the sudo commands will grant elevated permissions for 15 minutes in Ubuntu.

 

Recommended Article: Common Apache Errors Troubleshooting

How To Quickly Give Users sudo Privileges In Ubuntu

%admin ALL=(ALL) ALL
Note 1: As you see, the above command means that all members of the admin group have full sudo privileges. To add your user to the admin group, you would issue the command.
sudo usermod -a -G sudo USERNAME

Note 2: Obviously, USERNAME  is the name of the user to be added. After all, once the user logs out and logs back in, they will now enjoy full sudo privileges.

 

Creating A New Sudo-enabled User On Ubuntu 20.10

Let’s go through the steps (If you want to configure sudo for an existing user, skip to step 3) of this guide to learn how to create a new user with sudo access on Ubuntu 20.04 without having to modify your server’s /etc/sudoers file.

Step1: SSH into your server as the root user to log into your Server:

ssh root@your_server_ip_address

Step2: Use the adduser command to add a new user to your system:

adduser noodi

Note3: You should replace noodi with the username that you want to create. You will be prompted to create and verify a password for the user. Also, you will need to fill in some information about the new user. It is fine to accept the defaults and leave this information blank.

Step3: It is time to type the usermode command and add the user to the sudo group:

usermod -aG sudo sammy

Step4: At the final step, you should test that if the new sudo permissions are working are nor. You can use the su command to switch to the new user account:

su - sammy

Now that you created a new user, also verify that you can use sudo by prepending sudo to the command that you want to run with superuser privileges:

sudo command_to_run

From now on, you can list the contents of the /root directory which is normally only accessible to the root user:

sudo ls -la /root

Note4: You will be prompted for the password of that user’s account if this is the first time you are using sudo in a session.

Recommended Article: How to Fix mysqladmin flush-hosts Error in Linux

How To Delete Sudo Users

any time is needed, you can remove sudo permissions from a user. But you are able to do this without having to delete him/her completely. Be careful when you are removing a sudo user in Ubuntu systems and watch to not remove the real administrator from the “sudo” group. Consider that there should be at least one sudo user in the system.

Type the command below to revoke sudo permissions from a user:

sudo deluser ubuntuserver sudo

Note5: You may see your user name instead of “ubuntuserver” and consider that this command will only remove your preferred user from the sudo group, but it will not delete the user permanently from the system.

Also, you can run the following command to revoke the sudo permission from the user. In this way, the user becomes a regular user and can’t do any administrative tasks with sudo permission.

sudo gpasswd -d ubuntuserver sudo
Finally, you are ready to verify if the user has really been removed from “sudo” group, by typing the command below:
sudo -l -U ubuntuserver

How To Delete Users Permanently In Ubuntu 20.10 Server

As you reviewed till now, you have only removed the users from the “sudo” group. But what should be done about the user still exists in the system? If you need to remove a user completely from a Linux system, log in as root or sudo user and run

sudo deluser <username>

Also, you can remove a user along with their home directory and mail spool. Run the following command to do this:

sudo deluser --remove-home ubuntuserver

 

 

Conclusion

In this article, you learned How To set up Sudo Privileges For User In Ubuntu 20.10 Server. After all, If your user is in the proper group and you entered the password correctly, the command that you issued with sudo will run with root privileges. Also, you can read more on Initial server setup on Ubuntu 20.04.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

10 thoughts on “Tutorial Setup Sudo Privileges For User In Ubuntu 20.10

    1. To verify sudo access, you can switch users with the command of:
      su – newuser
      And replace ‘’newuser’’ with the username you entered while creating your new user.

    1. To verify user belongs to sudo group or not, you can run the command below:
      groups newuser
      And then you can view the list of username and all groups it belongs to

    1. When you need an easy way to switch or change to the administrative account in the current logged in session, su is the best choice as it is used to run a function as a different user

    1. Yes, as it is stood for SuperUser do, it has been designed to run only super user commands. Using the sudo command lets every one run a command as any user.

    1. In the list below you can see some open source sudo alternatives:
      1- The OpenBSD doas command is similar to sudo and has been ported to other systems.
      2- access.
      3- vsys.
      4- GNU userv.
      5- sus.
      6- super.
      7- priv.
      8- calife.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day