Skip to content

  • Lifestyle
  • Technology
  • Sports
  • Health
  • Travel
  • Toggle search form

How to add users on Linux

Posted on June 20, 2022 By admin No Comments on How to add users on Linux

fatmawati achmad zaenuri / Shutterstock.com

Adding users to a Linux computer is a basic management task, and there are several ways to achieve this. Each method has advantages and disadvantages. We explain three different techniques for you.

Computers Need User

A personal computer without a user is not really much. Linux supports more than one user. Whether they log in at the same time and share the power of the computer, or log in individually when using the machine exclusively, each person needs a unique user account.

A user account covers the work of that user and ensures confidentiality. It also allows you to control and manage your account. Different users may have different capabilities depending on their needs or role or function by changing the attributes of user accounts, for example, to which groups they belong.

Whether you share your computer with family members or manage multiple user setups for an organization, creating user accounts is a key administrative skill.

Since Linux is Linux, you have several ways to choose. We will go through three or two command line methods and one GUI based method so that you can choose the one that is most suitable for you.

useradd command

The useradd The command is the lowest level command used to add users. Acts as a friendly front for other commands useradd command. This adds a little flexibility and simplifies the process, but other commands do nothing you can’t get. useradd and help a little passwd command.

The useradd The command has many options, the ones needed to add a regular new user are listed below. Needless to say, you will have to use it sudo to add a user.

sudo useradd -s /bin/bash -m -c "Mary Quinn" -Gsambashare maryq

adding a typical user with useradd

The order consists of the following:

  • sudo: We need administrator privileges for a new user to access the computer.
  • add user: The useradd command.
  • -s / bin / bash: Shell selection. This sets the default shell for this new user.
  • -m: Option to create a home directory. This creates a directory with the same name as the new user account in the / home / directory.
  • -c “Mary Quinn”: Full username of the new user. This is optional.
  • -Gsambashare: Additional group selection. This is optional. A new username is added to the group with the same name. The -G option (note, large โ€œGโ€) adds the user to additional groups. Groups should already exist. We also make the new user a member of the sambashare group.
  • maryq: The name of the new user account. It must be unique. It can no longer be used for another user.

This creates a new user account, creates their home directory, and fills it with some standard hidden files. We can look at their home catalog as follows:

sudo ls -ahl /home/maryq

Standard configuration files added to the new user's home directory

Our new user will not be able to log in. We did not create a password for them. It is possible to pass a password to useradd command using -p (password) option, but this is considered a bad experience. You must also enter a password encrypted is in shape, so it is not as simple as it seems.

easier and safer to use passwd command to set a password for a new account.

sudo passwd maryq

Set a password for a new account

You will be asked for a password, then you will be asked to enter it again to verify it. This password must be safely communicated to the new user. It is recommended that they be asked to change their passwords when logging in. This means that they can choose their passwords and no one else will know.

sudo passwd --expire maryq

Setting a new user's password to an outdated state

By looking inside the / etc / passwd file, we can see our new user account and compare it to an existing account.

grep -E "dave|maryq" /etc/passwd

Comparison of new account / etc / passwd entries with new user account

Areas separated by two dots “:” in sequence:

  • maryq: User account name.
  • x: The “x” in this field indicates that the user account password is encrypted and stored in the / etc / shadow file.
  • 1001: User account ID.
  • 1001: The default group ID for this user account.
  • Mary Quinn: This is the GECOS area. It can store the separated values โ€‹โ€‹of additional information with a comma “”. All we added was the full name of the user.
  • / house / maryq: The path to the home directory for this account.
  • / bin / bash: The path to the standard shell for this account.

When our new user logs in for the first time, they will use the password you created for them.

A new user is logged in

They will be asked to change their password as we set it to “expired”. They must log in again available password.

Re-enter the current password as the first part of changing the user's password

Then they are asked for a new password.

Enter a new password

After they enter their new passwords and hit the “Enter” key, they are asked to re-enter the password to verify it.

The new password is being verified

Finally, they entered. They must then use a new password to log in.

Some homework is done, and the usual “Documents”, “Downloads” and other catalogs are created for them in the home directory.

Standard folders created within the user's home directory

The GECOS field can contain up to five commas. They are rarely used. If they are generally settled, he is usually the first to bear the real name of the owner of this account.

The areas are:

  • This is the real name of the user.
  • This is the user’s room number.
  • Their work phone.
  • Their home phone.
  • Any other information.

If we wanted to provide all of these when creating an account, we could do the following:

sudo useradd -s /bin/bash -m -c "Mary Quinn,Operations 1,555-6325,555-5412,Team Leader" -Gsambashare maryq

adding a new user with a filled GECOS field using useradd

we can use grep to see if this information is stored in the / etc / passwd file.

grep maryq /etc/passwd

We are looking at the entry in / etc / passwd for a new user with grep

If you do not have this information when you create an account, it can be added or changed later chfn command.

This information is used by commands as well finger and pinky.

finger maryq

Use the fingerprint command in a new user

Additional user command

The adduser The command includes creating an account, its home directory, setting a password, and entering GECOS field information into an interactive session.

The adduser the team was already available on our Ubuntu and Fedora test machines, but had to be installed at Manjaro. It is in the Arch User Repository, so you should use an AUR assistant like you. yay to install.

yay adduser

Use the bow on Manjaro to install the adduser

Use it to start the process sudo and enter the name of the user account you added:

sudo adduser maryq

A standard group is created for the user account and the user account is added to that group by default. The home directory is created and hidden configuration files are copied to it.

You are asked to provide a password.

Use the adduser to add a new user

When you enter the password and hit the “Enter” button, you will be asked to re-enter the password to verify it.

You will be asked in turn for any information that may be included in the GECOS field.

Setting a password for a new account using Adduser

Either give some information and press Enter to move to the next field, or just press Enter to move to the field.

Completed GECOS information in the Adduser command

Finally, you are asked if the information you provide is correct. Press the “Y” key and press the “Enter” key to complete the process.

Remember to set the password for the new account as “expired” so that the new user must change it the first time they log in.

sudo password --expire maryq

Setting a new user's password to an outdated state

GUI method

Open the system menu by right-clicking on the GNOME panel, next to the power, volume, and network icons.

GNOME system menu

Click on the “Settings” menu entry.

The settings program will open. Tap the “Users” entry in the sidebar, then click the “Unlock” button in the “Users” section.

Users panel in the settings application

You must enter your password.

Confirmation in the settings program

The green “Add User” button will appear.

Unlocked Users panel in Settings application

Click this button. The “Add User” dialog appears. It contains a form that captures the details of the new user.

Add user dialog

Fill out the form with the details of the new user. If you want them to use sudoClick the “Administrator” button.

You can either set their password now, or leave the password to them to choose the password when they first log in. If you set a password, you will need to open the terminal window and remember to use it. passwd command it to be set to “expired”. This will force them to set their own passwords the first time they log in.

Going to the terminal is a bit of a pain when you try to use the GUI to create a new user.

If you click the “Allow user to set their password the next time you log in” radio button, a new password is required when the user tries to log in. But the downside here is that you are the first person to try to use a new account. can set a password. Thus, anyone who knows that an account has been created and defeats a real new user to log in can capture the account.

None of these situations are ideal.

After filling out the form and making your selections, click the green “Add” button.

We selected the option “Allow the user to set his password the next time he logs in”. A new password is required when the user tries to log in. However, unlike the sequence we saw earlier, they are not required to have a current password – they do not have a password.

The new user is forced to choose a new password

As you would expect, they will have to re-enter it to check it out.

The new password is being verified

Decisions Decisions

The useradd The team gives granular control, but there is much to gain on the command line.

The adduser The command simplifies life, but does not allow the new user to be added to additional groups.

The password radio button you choose for the GUI method has its drawbacks.

In most informal or domestic situations, adduser The team probably gives the best balance between opportunity and functionality. If you need to add a new user to an additional group, you can do so after they are created usermod command.

RELATED: Add a User to a Group (or Second Group) on Linux

Technology

Post navigation

Previous Post: Meta offers a look at what you can watch in Quest 2, which sees the future of VR
Next Post: How To Choose The Best Trail Running Shoes In 2022

Leave a Reply Cancel reply

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

Archives

  • August 2022
  • July 2022
  • June 2022
  • May 2022

Categories

  • Health
  • Lifestyle
  • Sports
  • Technology
  • Travel
  • Uncategorized

Recent Posts

  • The Apprentice winner Harpreet Kaur has revealed that she is dating her co-star Akshay Thakarar.
  • Apple TV Plus: Every New TV Show Coming in August
  • Graeme Souness: Aston Villa’s Tyrone Mings never achieved anything but has a lot to say
  • Barcelona is racing against time in a desperate understanding on short-term legs Barcelona
  • Best Movies on Apple TV Plus

Recent Comments

  1. A WordPress Commenter on Hello world!
  • About us
  • DMCA
  • Privacy policy
  • Terms and conditions

Copyright © 2022 .

Powered by PressBook WordPress theme