Cover Image

# Create a sudo user on Arch Linux

June 1, 2023 - Reading time: 3 minutes

In the previous guide we installed Arch Linux (https://techwithkreplach.com/how-to-install-arch-linux-vm), but after installation our only user on the system is root.

It is safer to use linux as a different user than root, since this way there is less chance of you missclicking anything that can screw up the whole Operating System. Instead, every time you need to do something critical, the system will ask you for the sudo password.

Step 1

Create a new user:

useradd -m <USERNAME>

option -m creates a new directory for this user in /home.

Step 2

Create password for this user:

passwd <USERNAME>

this password will be used to log in into user. You will also have to type it every time when running a sudo command.

Step 3

Open sudoers file with text editor:

nano /etc/sudoers

Step 4

Add the following line right under "root  ALL=(ALL:ALL)  ALL" in section "# User privilege specification":

<USERNAME> ALL=(ALL:ALL) ALL

instead of <USERNAME> type the username you created in step 1. for example:
user1 ALL=(ALL:ALL) ALL

Close and save by clicking CTRL+X,then 'y' and ENTER

Step 5

Log in to the new user:

su - <USERNAME>

Step 6

Test that sudo works:

sudo pacman -Syu

"pacman -Syu" is a command that requires root privileges. If it runs then you have successfully created a new user with all sudo privileges.

ABOUT

Welcome, I am GalacticKreplach. This is my documentation blog for guides, fixes, bugs and updates. Enjoy the content, comment and share your insights.

Hit Counter

27