Linux - Arch How to Set up SUDO

2 min read

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/

Related Articles

vim

vim - How to Search & Replace

To search and replace in Vim, you can use the substitute command, which is represented by :s. Here's a step-by-step guide on how

Pipewire - Send Audio Over the Network

Super simplified article on how to receive microphone audio over the network. Receiver Host Creating the audio server. pactl load-module module-native-protocol-tcp port=8888 listen=192.

Linux - SSH Key Authentication

One of the most secure ways to connect to a system is with SSH key authentication that, combined with good firewall rules it can prevent