How To Create a Sudo User on CentOS 7/8
The sudo
command provides a mechanism for granting administrator privileges, ordinarily only available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on CentOS, without having to modify your server’s sudoers
file. If you want to configure sudo for an existing user, simply skip to step 3.
- Log in to your server as the root user.
ssh root@{server_ip_address}
- Use the adduser command to add a new user to your system.
adduser {username}
- Use the passwd command to update the new user’s password.
passwd {username}
- Use the usermod command to add the user to the wheel group.
usermod -aG wheel {username}
- add user to a {nginx} group
usermod -a -G {username} nginx
If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.