Linux - Arch How to Set up SUDO

Arch Linux is known to not be the most user friendly distro because it does not come with most of the packages other distros installs and configures by default.

sudo is well known tool that allows a system administrator to delegate authority to other users.

1) Installing Sudo

Let's install and basically configure sudo in our Arch box.

pacman -S sudo

After the installation you might want to change the default text editor used by visudo to edit the /etc/sudoers configuration file.

export EDITOR=vim
/etc/bash.bashrc

In my case, because I like to use vim I have added the above line to my bashrc file.

2) Adding a new Adminstrator

Let's create our new administrator.

useradd -c 'Management User' tiago

I am going to follow the tip on the Arch Linux wiki about adding new administrators to the system adding the recently created user to the wheel group.

usermod -a -G wheel tiago
Add the user the a group without removing it from other groups.
getent group wheel
wheel:x:998:tiago

3) Setting Permissions

It's time to allow the members of the wheel group to use sudo. Let's edit the sudoers file adding the below:

visudo
Launching the sudoers file.
...

##
## User privilege specification
##

# Allows the members of the group execute any commands, but not as any user. Only as root.
%wheel ALL=ALL

...
/etc/sudoers

Conclusion

With the steps above we have set up a basic adminstrator in our system. However, sudo is very powerful and extremely customisable. For more sophisticated settings and permissions check the links listed below and the file /usr/share/doc/sudo/examples/sudoers.

Resources

Sudo - ArchWiki
sudoers(5) — Arch manual pages
Polkit - ArchWiki
Environment variables - ArchWiki

https://linuxize.com/post/how-to-list-users-in-linux/

https://linuxize.com/post/how-to-list-groups-in-linux/