To add a sudo user on CentOS Linux 8, you will need to log in as the root user or another user with sudo privileges. Once logged in, you can use the following steps to add a new user and grant them sudo privileges:
useradd command to create a new user account. Replace <username> with the desired username for the new account:useradd <username>
passwd command. Replace <username> with the username of the new account:passwd <username>
visudo command to open the /etc/sudoers file in a text editor. This file controls who is allowed to use the sudo command.visudo
<username> with the username of the new user account:<username> ALL=(ALL) ALL
/etc/sudoers file. The new user should now be able to use the sudo command to run commands with elevated privileges.Note: It is recommended to use the
visudocommand to edit the/etc/sudoersfile, as it checks the file for syntax errors before saving it. This helps to prevent accidentally breaking thesudoconfiguration, which could prevent users from being able to usesudo.