Arch Linux

How to Add Users on Arch Linux

How to Add Users on Arch Linux
User management is one of the fundamental features of any Linux system. It allows distributing proper system permissions to the right person only. By default, Linux is a multi-user system. Multiple users can access the system and utilize appointed features at the same time. However, for a smooth and safe experience, proper account management is extremely crucial.

That's why account management is one of the major parts of being a system admin. There are so many crucial parts involved in the management that even the slightest mistake can cost the entire system taken over by unwanted intruder(s).

Today, let's check out on adding user account(s) on Arch Linux.

User accounts

A user is anyone who uses a computer. In the case of Linux users, it indicates the names that represent those users. While Linux allows a robust system for multiple user access at the same time, security is a big concern. Without proper permission control, the system can become vulnerable to all sorts of misuse.

For making the management easier, all the user accounts in a Linux system are separated into different groups. The groups are the actual definition of the users' power over the system. There are some default groups that are usually more than enough to handle the job. However, in the case of an enterprise-level system, more groups may be necessary. That's up to the system admins to decide whether more groups are needed or not.

In this guide, we'll be covering how to add, remove and manipulate various factors of a user account on Arch Linux.

Note: If you're testing on your home computer, feel free to wander around. However, if these actions are to be performed on a corporate or enterprise-level system, I strongly recommend exercising extreme caution. These actions are better performed by a sophisticated system admin rather than average Joes.

User account actions

There is a multitude of actions for managing the user accounts. The best way to do them is through the terminal. It allows greater control and understanding. Fear not; if you're willing to pay a bit more attention, it's nothing so special.

Enabling the “wheel” group

This is the very first important step. Without enabling the wheel group, adding admin account to the system is not possible.

We need to modify the “sudoers” file. Run the following command.

sudo EDITOR=nano visudo

This will launch the “/etc/sudoers” file with Nano editor. Now, scroll down and uncomment the “wheel” group.

Save the file by pressing “Ctrl + O” and exit the editor by pressing “Ctrl + X”.

The wheel group enables creating a user with the ability to run commands as “root”. Root holds the ultimate power of the entire system and if you're using Linux for quite some time, you already know the importance of running multitudes of maintenance and tweaks that require root access.

Adding a user

Now, we're ready to add a new user. The “useradd” command follows the following structure.

sudo useradd

Adding a new user in the system is quite simple. Just tell “useradd” the username.

sudo useradd

Unfortunately, this command will lock the user without any way of logging in. The user would also have no home directory. To alleviate the problem, use the following command structure.

sudo useradd -m

This will create a unique home directory for the user and let the new account to be accessible. Now, assign a login password for the newly created user.

Note: This command can also be used for updating the password of an existing account as well.

sudo passwd

It's possible to squeeze all the aforementioned steps in one single line.

sudo useradd -m -p

“useradd” is also capable of setting a custom directory for the newly created user. For that purpose, use the “-d” flag.

sudo useradd -d /path/to/home/dir -m -p

“useradd” is also capable of performing a lot of other functions. For example, the “-G” flag to define which group to register for.

sudo useradd -G -d /path/to/home/dir -m
-p

If you need to add a system user, use the following strucutre.

sudo useradd -r -s /usr/bin/fish

Need to verify the result? Try logging into the user account with the following command.

sudo su -
sudo whoami

Modifying user attributes

It's also important to know how to change the user attributes. In cases, a user might need changes in the permission and other attributes. For that purpose, we need the usermod tool. It's capable of altering a lot of attributes.

usermod follows the following structure.
sudo usermod

For example, you can change the login name of a user!

sudo usermod -l

Need to change the home directory for the user? Use the “-d” or “-home” flag.

sudo usermod -m -d /path/new/home

You can also set the expiry date of a user! After the time, the user will no longer be available on the system.

sudo usermod --expiredate

If a user needs to be registered in additional groups, use the “-append” and “-groups” flags together. When listing the groups, there must not be any space between the commas.

sudo usermod --append --groups

Change the default shell of an user using the “-shell” flag.

sudo usermod --shell

Like useradd, usermod also allows stacking all the parameters in one single line.

sudo usermod --expiredate --append --groups
--shell

If, for some reason, a user needs to be locked down, usermod can do the job.

sudo usermod --lock

The user can be enabled using the following command.

sudo usermod --unlock

Deleting a user

It's the final part of this guide. In the lifecycle, a system will have new users and in cases, old users will get removed/updated. For removing users, userdel is a dedicated tool.

Use the following command for removing a user.

sudo userdel

If you want to remove the user with associated home directory, use the following command.

sudo userdel -r

Final thoughts

These are just simple usage cases for all the methods mentioned before. There are plenty of other ways where these commands can offer a real solution.

For deeper and advanced usage of these commands, consult their man pages. There are all the available options you can use to use in the appropriate situations. Feel free to roam around and have a better understanding.

Cursor jumps or moves randomly while typing in Windows 10
If you find that your mouse cursor jumps or moves on its own, automatically, randomly while typing in Windows laptop or computer, then some of these s...
How to reverse Mouse and Touchpads scrolling direction in Windows 10
Mouse and Touchpads not only make computing easy but more efficient and less time-consuming. We cannot imagine a life without these devices, but still...
How to change Mouse pointer and cursor size, color & scheme on Windows 10
The mouse pointer and cursor in Windows 10 are very important aspects of the operating system. This can be said for other operating systems as well, s...