![]() ![]() Use the su command to switch to the new user account.Use the “usermod” command to add the user to the sudo group.īy default, on Ubuntu, members of the sudo group have sudo privileges.Ĥ. (enter the new value, or press ENTER for the default)ģ. You can opt to accept the defaults to leave all this information blank.Ĭhanging the user information for username: Follow the prompts to set the new user's information.I highly recommend that you use a secure password when setting this up. Set and confirm the new user's password at the prompt.(Make sure that you replace “derek” with the user that you want to create – unless you want me in your accounts, LOL) ssh Use the “adduser” command to add a new user to your system.Log in to your Ubuntu server as the root user. If you just need to configure sudo for an existing user, skip to step 3. Below I show you the simplest method to create a new user with sudo access-without needing to modify your server's sudoers file. The sudo command allows you to grant administrator privileges, usually only available to the root user, to regular users. If you are using Linux and you want your actions to be safe, you need to know and understand these two commands. Having root user privileges can be dangerous, but using sudo instead of su can help you keep your system more secure. Using “sudo,” you can do pretty much the same things you can with “su.” To use it, you just have to add “sudo” in front of all root commands. Once that time expires, you have to enter your password again to regain root privilege. Also, the root privilege in “sudo” is only valid for a finite time. With “sudo,” you continue to use your user account, but with root privilege, whereas in “su,” you are actually logged into the root account. This is different from “su” which is not temporary. Sudo stands for either "substitute user do" or "super user do" and it allows you to temporarily elevate your current user account to have root privileges. The Unix command su, stands for “substitute user,” “super user,” or “switch user,” and allows you to log in as root and do whatever you want with the system. I am going to refer to Ubuntu in this blog. Some types, such as Fedora, Red Hat, and openSuSE enable the root user, while others, such as Ubuntu and Debian, do not. Which one you use will depend on which type of Linux you have. You can either change over to the super user, also known as the root account, using the “su” command, or you can use the “sudo” command. If you found the article helpful, make sure to comment below and subscribe to geekbits.When it comes to working with Linux, there are two ways to run administrative applications. These are some of the most important tasks a system admin should know how to do. In this article, you have learnt how you can add a user to the sudo group and remove him from the group as well. ![]() Notice that the user can no longer use the sudo command because he is not in the sudoers file. Let's try to make a directory with the sudo command. su - geekbitsĮnter the password for geekbits to continue. Now that the user geekbits is removed from the sudo group, let's login to geekbits and try to use the sudo command. You can confirm with the following command. Geekbits is now removed from the sudo group. To remove geekbits from the sudo group, we'll use the deluser command as follows. Removing a User from the sudo groupĮxit from geekbits user by typing exit and pressing Enter. Now let's see how you can remove this user from the sudo group. You can now use sudo command with the new user. Switch to the newly created account with the following command. You will notice that geekbits can run all the command on the system. You can confirm that the user was added to the group with the following command. The command adds the user geekbits to the sudo group. Using the usermod commandįollow the steps below to grant "geekbits" sudo rights with the usermod command. ![]() Now that the user is created, the method below will give "geekbits" access to sudo by adding this user to the sudoers file. The command above will create a user with the name "geekbits". ![]() To create a new user, use the following command. To use this method, the user must exist in the system. In this article, we'll use the usermod command. There are several ways to do this with the command line. Claim your free $200 credit on DigitalOcean now! Granting sudo Rights Through the CLI ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |