How to Add Users on Arch Linux

29/12/2020
Chưa phân loại
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 <options> <username>

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

sudo useradd <username>

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 <username>

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 <username>

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

sudo useradd -m <username> -p <password>

“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 <username> -p <password>

“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 <groups> -d /path/to/home/dir -m <username>
 -p <password>

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

sudo useradd -r -s /usr/bin/fish <username>

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

sudo su<username>
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 <options> <username>

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

sudo usermod -l <new_username> <old_username>

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

sudo usermod -m -d /path/new/home <username>

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 <YYYY-MM-DD> <username>

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 <group1,group2,…> <username>

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

sudo usermod –shell <shell_path> <username>

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

sudo usermod –expiredate <YYYY-MM-DD> –append –groups <group1,group2,…>
 –shell <shell_path>

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

sudo usermod –lock <username>

The user can be enabled using the following command.

sudo usermod –unlock <username>

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 <username>

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

sudo userdel -r <username>

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.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Unity3D Tutorial

Introduction to Unity 3D Unity 3D is a powerful game development engine. It is cross platform that is it allows you to...
28/12/2020

Có nên thuê proxy nuôi TikTok hay không?

Có nên thuê proxy nuôi TikTok hay không? Đây là câu hỏi mà nhiều người đang đặt ra khi muốn tạo...
02/10/2023

How to Create a Custom Application Launcher with Quicklist in Linux

Many popular applications come with quick shortcuts that can be used to execute a specific action. If you right click on...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Hướng Dẫn Chọn Dịch Vụ Thuê Địa Chỉ IPv4
10/03/2025

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024