Arch Linux is a GNU/Linux distribution that strives to provide the latest stable versions of its packages, while providing cutting-edge desktop environments, window managers and utilities.
It is almost always useful to add a user without administrator privileges to perform common tasks. You must also create additional accounts for any other users you may have on your system. Each user must have a different account.
You can still acquire administrator privileges when you need them through the sudo command .
In this guide, we will show you how to create user accounts, add add user to group, sudo privileges, and delete users.
How to add a user in Arch Linux
If you are logged in as root, you can create a new user at any time by typing:
If you are logged in as a non-root user who has been granted sudo privileges, you can add a new user by typing:
sudo useradd linuxguidehq
To set a password for the newly created user, type the following command:
sudo passwd linuxguidehq
Your new user is now ready to use. Now you can log in with the password you set.
To see a list of all users on the system:
cut -d: -f1 /etc/passwd
To log in with the new user just created, from the terminal:
If you want to use the root user again:
What are users and groups in Linux?
Users and groups are used in GNU / Linux for access control, that is, to control access to files, directories, and system peripherals. Linux offers relatively simple / crude access control mechanisms by default.
How do I list all users in Linux?
To list users on Linux, you must run the “cat” command in the “/ etc / passwd” file.
Running this command will present you with the list of users currently available on your system. Alternatively, you can use the “less” or “more” command to navigate within the list of usernames.
What is the default group in Linux?
A user’s primary group is the default group that the account is associated with. Directories and files that the user creates will have this group ID. A child group is any group that a user other than the parent group belongs to.
How to assign sudo privileges to a user
To allow the new user to run commands with root (administrative) privileges, you will need to grant them access to sudo . Let’s look at two different approaches: adding the user to the default sudo group and specifying per-user privileges in sudo settings.
Add the new user to the Sudo group
By default, sudo is configured to extend all privileges to any user in the sudo group.
You can see which groups your new user is in with the groups command :
Output linuxguidehq: linuxguidehq
By default, a new user is only in their own group, which is created when the account is created.
How to assign sudo privileges in / etc / sudoers
To associate sudo privileges with a new user, open the configuration file named / etc / sudoers with the visudo command .
f you are currently logged in as root, type:
If you are logged in as a non-root user with sudo privileges, type:
Find the following line of code:
root ALL=(ALL:ALL) ALL
The default editor the file will open in is vi .
Add a new line to assign sudo privileges to our new user like this:
root ALL=(ALL:ALL) ALL linuxguidehq ALL=(ALL:ALL) ALL
You need to add a new line like this for each user who must have full sudo privileges.
Save and close the file.
How to delete a user in arch linux?
In case you no longer need a user, it is better to delete the account.
You can delete the user himself, without deleting any of his files, by typing as root:
If you are logged in as another non-root user with sudo privileges, you can type:
sudo userdel linuxguidehq
If you also want to delete the user’s home directory when it is deleted, you can use the following command as root:
userdel -r linuxguidehq
If you are running this as a non-root user with sudo privileges, you will need to type:
sudo userdel -r linuxguidehq
If you previously set sudo privileges for the user you removed, you may want to remove the previously entered line in the / etc / sudoers file again by typing:
Or use this if you are not a root user with sudo privileges:
root ALL=(ALL:ALL) ALL linuxguidehq ALL=(ALL:ALL) ALL # CANCELLA QUESTA RIGA
This will prevent a new user created with the same name from accidentally receiving sudo privileges.