Sudo allows a user to run commands or programs with the security privileges of another user ( by default superuser). Superuser in Linux is called 'root'.
It is one of the best security practices is to use non-root user to perform server administration.
In this quick article, we are going to create a user and add to a sudo group in Arch Linux.
Adding User to the sudo group
As mentioned before sudo command allows you to run programs with the privileges of the superuser. In Arch Linux, sudo is not part of the base installation. So, if you haven't install sudo, then install with the following command.
# pacman --sync sudo
Also, install vi editor.
# pacman --sync vi
Now, add a user also state to make its home directory by option --create-home
# useradd --create-home john
Assign password,
# passwd john
Wheel group is the sudo group in Arch Linux. So at this point add newly created user 'john' to the wheel group with the help of command usermod.
# usermod -aG wheel john
Now edit the file sudoers so that the wheel group is activated. To do this, open the sudoer's file and uncomment the line %wheel ALL=(ALL) ALL
# visudo
The final outcome should be like:
Save and exit visudo. Press Esc then : wq and press Enter
Now, test your configuration by switching to user john and using id command to show the group. You should see root when you type the command sudo whoami.
# su - john
$ id
$ sudo whoami
Removing users from the Sudoers group
If you like to remove a user from sudo ( wheel group) use gpasswd tool as below. In our case, the user is john,
# gpasswd -d john wheel
Conclusion
We showed you how to add user to sudo group on Arch Linux. We suggest you use sudo user rather than the root user while performing the administrative tasks. This also helps to provide appropriate permission to the right person. Thank you for getting here.
Comments