Why when I try to change user I obtain this error message? “myusername is not in the sudoers file”

0

I am not so into Linux and I have the following problem.

I have to change user (using a given user) on a Linux server.

So I use the

[myusername@myserver~]$ sudo -i -u otherusername
[sudo] password for myusername:
myusername is not in the sudoers file.  This incident will be reported.
[myusername@myserver~]$

So it seems that I have not permission to do it or something like this. What extactly is the problem?

AndreaNobili

Posted 2017-02-03T09:45:04.410

Reputation: 5 433

https://xkcd.com/838/ – Kamil Maciorowski – 2017-02-03T19:29:47.740

Answers

1

sudo is a command that lets you run another command with elevated permissions (i.e. root). The file /etc/sudoers controls which users can do this. Editing this file needs root permissions for obvious reasons.

If you don't have access to the root account to add your own user to this file, other alternatives to switch to another account are:

$ exit 
[log in as other user]

or

$ su - [other username]

But both of these require you to know the other user's password.

Darren

Posted 2017-02-03T09:45:04.410

Reputation: 2 435

If you login as the root user, am I correct in assuming you can sudo visudo and change the SUDO group to %ALL or alternatively sudo usermod user -aG sudo? – DankyNanky – 2017-02-05T09:26:01.627