How to Create and Add a Sudo User on Arch Linux
You’ll learn how to spin up a new account and give it the same power as root, but with that handy safety net of `sudo`. No more logging in as root or juggling permissions like a circus act.
Why You Need a Sudo User
When you’re tinkering on an Arch system, you want the freedom to install drivers, tweak kernel parameters, and run package managers without risking a catastrophic root misstep. A sudo‑enabled user lets you do just that, while keeping the “do it right” habit alive.
Make Sure `sudo` Is Installed
pacman -Syu sudo
If `sudo` is missing, any attempt to elevate will fail and you’ll be left shouting at a dead prompt. Installing it first keeps the rest of the process painless.
Create the New Account
useradd -m -G wheel <username> passwd <username>
Why this matters: `-m` creates a home directory (you don’t want to be sharing `/root`). Adding the user to the `wheel` group is Arch’s convention for sudoers, so you avoid juggling individual entries later.
I once had a friend who tried to create a plain account, then forgot to add it to wheel. The result? A frantic “sudo: unknown user” error that took a half‑hour to debug.
Grant Sudo Privileges
EDITOR=vim visudo
In the editor, find the line that looks like:
# %wheel ALL=(ALL) ALL
Uncomment it (remove the `#`) and save.
Directly editing `/etc/sudoers` with a text editor is tempting but risky; if you leave a typo in there, you can lock yourself out entirely.
Verify It Works
su - <username> sudo whoami
You should see `root`. If it asks for your password and then prints `root`, congratulations—you’ve got sudo working on that account.
A good sanity check: try `sudo pacman -Syu` to confirm you can update the system without being root.
That’s all there is to it. You now have a fully functional user with just enough power to do serious work while still protecting your system from accidental missteps.