Arch

How to Add a User in Arch Linux

Giving access of a single system to multiple users becomes easy by creating separate user accounts for each user. Moreover, by doing so the permissions of each user can be adjusted depending on their role, which makes it easy to monitor the tasks carried out by each user. On Arch Linux, multiple users can be added by creating their user accounts. Users can also be added in groups, as this makes it less difficult to assign permissions to all same-level users.

Outline:

How To Add a User in Arch Linux

In Arch Linux, the process of adding a user is simple, primarily there are two types of users, one with administrator privileges and the other without administrator privileges. Furthermore, there are different groups in every Linux distribution that deal with the permissions for accessing (reading, writing, and executing) any file or data of the system. On Arch Linux, there are two ways to add a user, which are:

Through useradd Command

To add a user in Arch Linux, whether you want an administrator user or a simple user with limited permissions, useradd command is normally used. However, the process for creating both the users is different:

1: Adding a User without administrator privileges

To create a simple user, just use the useradd command along with the m flag, which is responsible for creating a separate directory for the new user:

useradd -m username

Once the user is created, set the password for the user by using the passwd command:

passwd <User-name>

Alternatively, you can set the password while creating a user, and for that use the p flag for it:

sudo useradd -m <user-name> -p <user-password>

Once the user is created, you can verify it by executing the awk command:

awk -F':' '{ print $1}' /etc/passwd

Further to confirm the permissions about the user simply login to it through the terminal and execute whoami command:

sudo whoami

2: Adding a User with Administrator Privileges

Unlike the other Linux distributions, Arch Linux has a group called wheel which is considered as a sudo group, so to create a user with administrator rights use the G flag along with its name:

sudo useradd -m -G wheel <User-name>

In the sudoers file of Arch Linux you will find a group named sudo but adding a user to that group won’t be possible as the sudo group is replaced by the wheel group. You can see the error of group sudo doesn’t exist in the image below:

Further, if at any instance you want to give administrator rights to a nonadministrator user, then use the usermod command along with the a and G flag. Here, the a flag is used to append a user to the supplementary group and is only valid with the G flag:

sudo usermod -a -G wheel <use-name>

Alternatively, you can add the user with administrator rights by giving it access to all the permissions to modify the system. For that, add the following line along with the username in the Arch sudoers file:

%<user-name> ALL=(ALL:ALL) ALL

Next, just create the user with the same name given in the sudoers file:

sudo useradd -m <user-name>

Now set the password for the administrator user:

sudo passwd <user-name>

Upon verification of the created user you will see the root in the output which means this Arch user has admin rights:

sudo whoami

Further, you can verify the permission by listing the commands by using the l flag:

sudo -l

Through System User Settings

Another method for adding a user in Arch Linux is by navigating it to the system user settings. Once you are in the user settings, unlock them first by password authentication:

Next, click on the Add User option at the bottom and then add the details for the new user which include its name, username, and password. Here you will see the option for giving the user administrator rights, so to make an administrator user turn it on. You can also set the password on the user’s first login and once you are done with entering the details, just click Add:

Now the new user will be listed below at the bottom:

Adding a User to a Group

Adding users to a group on Arch is beneficial if each user has been assigned a specific role, and then assigning them each to a group can segregate the users. This will help in managing and organizing the user access to the system:

sudo groupmod -a -U <user-name> <group-name>

Modifying User Details in Arch Linux

Once you have added the user in Arch Linux, you can modify or change its details by executing usermod command. Like if you want to change the shell for any user, then in that case use the s flag along with the username and shell name:

sudo usermod -s <shell-name> <user-name>

In all the Linux systems each user has its identification number that represents the user in the Linux kernel so on Arch Linux you change the user identification number for various reasons like reorganizing user accounts, migrating across different platforms or changing the permissions:

sudo usermod -u <new-UID> <user-name>

Note: There are some drawbacks for changing the UID like breaking the ownership and permissions, causing compatibility issues or creating security risks if not done properly.

The next thing that you can modify is adding small information about the user which clarifies the role of the user. For that, use the c flag along with the usermod command:

sudo usermod -c "<info-to-be-added>" <user-name>

How To Switch Users in Arch Linux

Once the user is created, you can switch to that new user if you want to install any applications or set up any file or folder. There are two ways to switch a user on Arch, one is by using the GUI and the other one is by using the terminal. Through GUI click on the power icon on the top right side and from the drop-down menu select Switch User:

Now login to the new user you created:

To switch to another user on Arch through the terminal is fairly simple, just execute the su command along with the username:

sudo su <user-name>

How To Remove a User from Arch Linux

Just like creating a user has different ways, deleting or removing a user can be done in different ways. So if you haven’t created a separate directory for the user, then execute the userdel command along with the username:

userdel <user-name>

If you have created a separate directory and created a mail spool for that user, then use the r flag with the userdel command:

userdel -r <user-name>

If the user is already logged in then you will receive an error of user is currently used by process so in that case you need to kill the process related to that username:

sudo killall -u <user-name>

Once you have terminated all the processes then remove the user by using the f flag which will force the removal of the user account along with the userdel command on Arch and don’t forget to use sudo:

sudo userdel -f <user-name>

Alternatively, you can remove a user from Arch by system user settings first unlock the settings and then click on the user you want to remove, there select the Remove User option:

Conclusion

Adding a user in Arch can be useful if you want to give restricted or administrator access to any other user. For adding the user on Arch there are two ways, one is by using the useradd command and the other is through Arch user settings. For giving administrator rights to a user, add it to wheel group in Arch by using the usermod command along with the G flag.

Similar Posts