On the Linux operating system, one needs to use the sudo command to provide admin-level access. In other words, the sudo command grants admin privileges to ordinary users. This page shows how to create a new user with admin (sudo) access on both Ubuntu/Debian and CentOS/RHEL servers. Please note that the following commands will update /etc/passwd, /etc/group, and /etc/shadow files.
Create a new user account with admin (sudo) access on Ubuntu or Debian Linux
Commands to add or create a sudo user (admin) on an Ubuntu or Debian Linux server:
- Open the terminal application
- For remote Ubuntu/Debian server use the ssh command and log in as the root user using either su or sudo.
- Create a new user named marlena, run: adduser marlena
- Make marlena user ‘sudo user’ (admin) run: usermod -aG sudo marlena
- Verify it by running the id marlena command
- Log in as marlena: su - marlena. Than run sudo command for verification. For example: sudo ls -l /etc/shadow
A note about granting sudo account for an existing Ubuntu/Debian Linux user
The syntax is (must run as the root user):
# adduser {UserNameHere} sudo
## add user named 'sai' to sudo group ##
# adduser sai sudo
Another syntax:
usermod -aG sudo UserNameHere
Log in as the root user and add an existing user accout named ‘sai’ to sudo group:
usermod -aG sudo sai
id sai
See “How to create a new sudo user on Ubuntu Linux server” for more info.
RHEL or CentOS create a new user account with admin (sudo) access
Procedure to add or create a sudo user (admin) on CentOS or RHEL:
- Open the terminal application
- For remote CentOS server use the ssh command and log in as the root user using either su or sudo.
- Create a new CentOS user named vivek, run: useradd vivek
- Set the password, execute: passwd vivek
- Make vivek user ‘sudo user’ on CentOS/RHEL, run : usermod -aG wheel vivek
- Verify it by running the id vivek command
How to grant sudo access for an existing RHEL/CentOS Linux user
The syntax is as follows for the usermod command and id command:
# usermod -aG wheel User-Name-Here
Add an existing user account named kirsh to wheel group. In other words, type the following two commands:
# usermod -aG wheel krish
# id krish
See Add / Create a Sudo User on CentOS Linux 8 for more info.
Conclusion
You learned how to create a sudo (admin level access) user account on both Ubuntu/Debian and RHEL/CentOS Linux servers. See sudo docs here.
- Linux Login as Superuser ( root user )
- How can I log in as root?
- Ubuntu create a new sudo user on Ubuntu Linux server
- Add a new user account with admin access on Linux
- CentOS 8 Linux create a Sudo User
- Ubuntu 20.04 LTS create a sudo user
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
Still have a question or comment? Post it on the forum thread here.