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.
Creating the user
Section titled “Creating the user”Replace alice with the name you want.
On Debian and Ubuntu:
adduser aliceusermod -aG sudo aliceadduser asks for a password twice and some optional details. Press Enter to skip the details.
On Rocky Linux, AlmaLinux and other RHEL based systems:
useradd -m alicepasswd aliceusermod -aG wheel aliceTesting sudo
Section titled “Testing sudo”Switch to the new user and run a command with sudo:
su - alicesudo whoamisudo 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.
Logging in as the new user with SSH keys
Section titled “Logging in as the new user with SSH keys”To log in as the new user with the same SSH keys as root, copy them over as root:
cp -r ~/.ssh /home/alice/chown -R alice:alice /home/alice/.sshThen connect with ssh [email protected].