sudo
stands for either "superuser do" or "switch user do", and sudo
users can execute commands with root/administrative permissions, even malicious ones. Be careful who you grant sudo
permissions to – you are quite literally handing them the key your house.
Before creating a new sudo
user, you must first create a new user.
How to Create a New User
Use adduser
or useradd
to add a new user
sudo adduser username
Be sure to replace username
with the user that you want to create. Also, note that to create a new user, you must also be a sudo
user yourself.
Use passwd
to update the new user's password
sudo passwd username
A strong password is highly recommended!
Give the New User Sudo Permissions
After creating a new user, add them to the appropriate group using the usermod
command.
On Debian systems (Ubuntu / Linux Mint / ElementryOS), add users to the sudo
group
sudo usermod -aG sudo username
On RHEL based systems (Fedora / CentOS), add users to the wheel
group
sudo usermod -aG wheel username
How to Delete a User
To delete a user, use the following commands.
Debian based systems (Ubuntu / Linux Mint / ElementryOS)
sudo deluser username
RHEL based systems (Fedora / CentOS)
sudo userdel username
That's all you need to know about creating a new sudo
user in Linux. And remember, "With great power comes great responsibility."