{"id":8792,"date":"2020-07-19T07:58:38","date_gmt":"2020-07-19T11:58:38","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=8792"},"modified":"2021-12-04T07:43:59","modified_gmt":"2021-12-04T07:43:59","slug":"add-users-ubuntu-20-04","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/add-users-ubuntu-20-04\/","title":{"rendered":"How to Add Users on Ubuntu 20.04 With adduser Command-line Tools"},"content":{"rendered":"\n
Here we will be showing you how to add users to Ubuntu 20.04. In all fairness, the steps here also apply to previous Ubuntu<\/a> versions and even other Linux<\/a> distros. Adding users to any Linux system is a simple but very important task to do while setting up your system.<\/p>\n\n\n\n By default, a fresh installation of Ubuntu gets you one user who happens to be the root user. This user has administrative rights on your system and that makes it potentially very destructive if used wrongly or in the hands of unauthorized users.<\/p>\n\n\n\n The general rule is to create at least one other user with sudo<\/em> privileges that can perform administrative tasks on-demand using the sudo<\/em> command. This is the user you would generally use to sign into the system.<\/p>\n\n\n\n Because we are using Ubuntu 20.04 in this guide, you will need to have authorized root access to a server running Ubuntu 20.04. If you haven’t already, you can set this up using this initial server setup guide for Ubuntu 20.04<\/a>.<\/p>\n\n\n\n When signed in as the root user, create a new user at any time by typing the following:<\/p>\n\n\n\n Or if you are signed in as a non-root user then use the following command:<\/p>\n\n\n\n Where newuser<\/em> is the username you are planning to use. You will then be presented with a series of prompts requiring you to:<\/p>\n\n\n\n Your new user is now ready for use and you can log in to the system using the password that you set. This user will not have any root (administrative) privileges. if you want administrative rights activated you can do so by following the next step.<\/p>\n\n\n\n To grant user root (administrative) privileges they need to be given access to sudo<\/em> by adding the user to a pre-defined sudo<\/em> user group. By default on Ubuntu systems, any user in the sudo<\/em> group is extended full system privileges.<\/p>\n\n\n\n You can verify what groups your new user is in by running the following groups command:<\/p>\n\n\n\n With the following output expected<\/p>\n\n\n\n By default, adduser<\/em> command creates a group with the same name as the new user and places the user in that group. To add the user to another existing group we can run the following usermod<\/em> command:<\/p>\n\n\n\n The -aG option here tells usermod<\/em> to add the specified user (newuser) to the listed groups (sudo).<\/p>\n\n\n\n You can explicitly specify privileges on a per-user basis by editing the \/etc\/sudoers<\/em> configuration file. This should be done using the visudo<\/em> command and not directly that way it locks the file against multiple simultaneous edits and performs a sanity check on its contents before overwriting the file. This protects a situation where you misconfigure sudo<\/em> and are locked out from fixing the problem because you have lost sudo<\/em> privileges.<\/p>\n\n\n\n If you are currently signed in as root, type:<\/p>\n\n\n\n Or, if you are signed in as a non-root user with sudo<\/em> privileges, type:<\/p>\n\n\n\n visudo<\/em> will open \/etc\/sudoers<\/em> in the system’s default editor which is usually nano.<\/p>\n\n\n\n Search for or scroll to the line that reads as follows:<\/p>\n\n\n\n Add a new matching line below it but change root <\/em>to your new user to look something similar to the example below:<\/p>\n\n\n\n Repeat for any additional user that you would like to assign sudo<\/em> privileges. When you are done save and close the file by hitting CTRL+S<\/strong> then CTRL+X<\/strong>. You can also just hit CTRL+X<\/strong>, followed by Y<\/strong>, and then ENTER<\/strong> to confirm.<\/p>\n\n\n\n Your new user is able to execute commands with administrative privileges. You can test this by running a command with elevated privileges:<\/p>\n\n\n\n You will be prompted to enter the user’s password.<\/p>\n\n\n\n Next, we will show you how to delete users on Ubuntu 20.04.<\/p>\n\n\n\n You should now have a good idea of how to add users to Ubuntu 20.04 with adduser and visudo command-line utilities. You should also be able to manage those users by elevating them with root or administrative privileges. You can also find out how to delete users on your Linux system here<\/a> as well as delete user groups on the Linux system<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" Here we will be showing you how to add users to Ubuntu 20.04. In all fairness, the steps here also apply to previous Ubuntu versions and even other Linux distros….<\/p>\n","protected":false},"author":1,"featured_media":8794,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,16],"tags":[121,193,313,354,431,433,526,531,573,591,598],"yoast_head":"\nPrerequisites<\/h2>\n\n\n\n
Add Users<\/h2>\n\n\n\n
# adduser newuser<\/code><\/pre>\n\n\n\n
$ sudo adduser newuser<\/code><\/pre>\n\n\n\n
Grant Sudo Privileges to a User<\/h2>\n\n\n\n
$ groups newuser<\/code><\/pre>\n\n\n\n
newuser : newuser<\/code><\/pre>\n\n\n\n
$ usermod -aG sudo newuser<\/code><\/pre>\n\n\n\n
Specifying Explicit User Privileges<\/h2>\n\n\n\n
# visudo<\/code><\/pre>\n\n\n\n
$ sudo visudo<\/code><\/pre>\n\n\n\n
root ALL=(ALL:ALL) ALL<\/code><\/pre>\n\n\n\n
root ALL=(ALL:ALL) ALL\nnewuser ALL=(ALL:ALL) ALL<\/code><\/pre>\n\n\n\n
root ALL=(ALL:ALL) ALL<br>newuser ALL=(ALL:ALL) ALL<\/code><\/p>\n\n\n\n
$ sudo command<\/code><\/pre>\n\n\n\n
Conclusion<\/h2>\n\n\n\n