Skip to content

Creating a Sudo User

A sudo user is a regular user that runs commands without admin rights. Prefix a command with sudo when it needs admin rights. A mistake as a sudo user does less damage than a mistake as root.

Replace alice with the name you want.

On Debian and Ubuntu:

Terminal window
adduser alice
usermod -aG sudo alice

adduser asks for a password twice and some optional details. Press Enter to skip the details.

On Rocky Linux, AlmaLinux and other RHEL based systems:

Terminal window
useradd -m alice
passwd alice
usermod -aG wheel alice

Switch to the new user and run a command with sudo:

Terminal window
su - alice
sudo whoami

sudo asks for the new user’s password. If it prints root, the user has sudo access. If it prints “alice is not in the sudoers file”, the usermod command did not run.

To log in as the new user with the same SSH keys as root, copy them over as root:

Terminal window
cp -r ~/.ssh /home/alice/
chown -R alice:alice /home/alice/.ssh

Then connect with ssh alice@203.0.113.10.