Creating a Sudo-Enabled User – IONOS Help
CentOS 7, CentOS Stream 8, and CentOS Stream 9
To assign sudo privileges to a user in CentOS 7, CentOS Stream 8, and CentOS Stream 9, you must add the user to the wheel group. To add the user to this group, enter the following command:
[root@localhost ~]# usermod -aG wheel USERNAME
Example:
[root@localhost ~]# usermod -aG wheel jsmith
To check if the change was successful, enter the following command:
localhost:~ # groups USERNAME
Example:
localhost:~ # groups jsmith
Debian and Ubuntu
To assign sudo privileges to a user in Debian and Ubuntu, you must add the user to the sudo group. To add the user to this group, enter the following command:
[root@localhost ~]# usermod -aG sudo USERNAME
Example:
[root@localhost ~]# usermod -aG sudo jsmith
To check if the change was successful, enter the following command :
localhost:~ # groups USERNAME
Example:
localhost:~ # groups jsmith
Suse Linux
To assign sudo privileges to a user in Suse Linux, do the following:
Locate the system-group-wheel and system-user-mail packages. To do this, enter the following command:
localhost:~ # zypper se wheel mailTo install the packages, enter the following commands:
localhost:~ # sudo zypper install system-group-wheel
localhost:~ # sudo zypper install system-user-mailOpen the /etc/sudoers file using the vim editor. Enter the following command:
localhost:~ # visudoMake sure that the commenting has been removed in the following lines. If necessary, remove the # character at the beginning of the line: # Defaults targetpw # ask for the password of the target user i.e. root
And also this line:
# ALL ALL=(ALL) ALL # WARNING! Only use this together with ‘Defaults targetpw’!