After logging into ssh, I got this message:
\'Username\' is not in the sudoers file. This incident will be reported.
How can I r
Add your user to the list of sudoers. This will make it easier to execute commands as the user that you have created will require admin privileges.
sudo adduser username sudo
(Note:- Username is the user you want to give the privileges)
First, switch/ log into the root user account or an account that has sudo privileges.
Next add the user to the group for sudo users:
If you're on Ubuntu members of the sudo group are granted with sudo privileges, so you can use this:
sudo adduser username sudo
If you're on CentOS members of the wheel group are granted with sudo privileges, so you can use this::
usermod -aG wheel username
Note: Replace username with your desired username
.
To test the sudo access, log into the account that you just added to the sudo users grouP, and then run the command below using sudo
:
sudo whoami
You will be prompted to enter the password. If the user have sudo access, the output will be:
root
If you get an error saying user is not in the sudoers file, it means that the user doesn’t have sudo privileges yet.
That's all.
I hope this helps
At the top of the aforementioned /etc/sudoers
file there's an info:
"## This file MUST be edited with the 'visudo' command as root."
In order of doing as we're told, use:
$ su
> Enter root password: *******
$ visudo -f /etc/sudoers
Find the following section of /etc/sudoers
file and add your users privileges:
# User privilege specification
root ALL=(ALL:ALL) ALL
user_name ALL=(ALL) ALL
Save the file (press esc and type :x
if vim is your default text editor, for nano press ctrl+o, enter and then ctrl+x).
Type exit
to turn off the root
shell, and enjoy the power of sudo
with your username
Entered Root using command $ su root
. Input Root Password
Install sudo: $ apt-get install sudo -y
Add your < username> $ adduser <username> sudo
$ exit
Then sign up and sign in the < username> session
Finally, check with: < username>@< hostname>:~$ sudo apt-get update
If you're unable to find visudo on your system
whereis visudo
Launch this tool
./PATH/visudo
add this line under
User privilege specification
user_name ALL=(ALL) ALL
Save the changes and here you go !
Got a slightly different syntax to Rodney's from my host
usermod -aG wheel username
Their explanation was
The user will need to be added to the wheel group.
Use the usermod command to add the user to the wheel group.
You may need to log off and log back in after doing this