Skip to content

Manage New User

Managing New User

Since Linux is a multi-user operating system, several people may be logged in and actively working on a given machine at the same time. Security-wise, it is never a good idea to allow users to share the credentials of the same account. In fact, best practices dictate the use of as many user accounts as people needing access to the machine. At the same time, it is to be expected that two or more users may need to share access to certain system resources, such as directories and files. User and group management in Linux allows us to accomplish both objectives.

Adding a New Regular Account

adduser <account-name>

You may be prompted to set the new user's initial password, and other optional information (such as full name, work phone, etc). This will be stored in /etc/passwd using colons as field separators. If not, you can assign a password for the newly created account named <account-name> with:

passwd <account-name>

When a new user is added, a group with the same name is created automatically. This is called a primary group

Granting Administrative Privileges

Now we have a new user account with regular account privileges. However, we may sometimes need to do administrative tasks. To avoid having to log out of our normal user and log back in as the root account, we can set up what is known as superuser or root privileges for our normal account. This will allow our normal user to run commands with administrative privileges by putting the word sudo before the command.

To add these privileges to our new user, we need to add the user to the sudo group. By default, on Ubuntu 20.04, users who are members of the sudo group are allowed to use the sudo command.

As root, run this command to add your new user to the sudo group:

usermod -aG sudo <user_name>

Now, when logged in as your regular user, you can type sudo before commands to run them with superuser privileges.