Avatar of A A
A A
 asked on

Receive error when trying to change to root

Hi experts

kindly be informed that I receive this error when try to do sudo su

sudo:unable to stat/etc/sudowers :permission denied

sudo: no valid sudoers sources found ,quitting

sudo: unable to unitialize policy plugin 
LinuxLinux Security* permission* Sudo

Avatar of undefined
Last Comment
serialband

8/22/2022 - Mon
serialband

Did you delete the /etc/sudoers file?  Did you change the permissions on /etc/sudoers?
serialband

Also sudo su is a dumb way to become root, unless you have some really ancient version of sudo.

man sudo
...
       -i, --login Run the shell specified by the target user's password database
                   entry as a login shell.  This means that login-specific
                   resource files such as .profile, .bash_profile or .login will
                   be read by the shell.  If a command is specified, it is passed
                   to the shell for execution via the shell's -c option.  If no
                   command is specified, an interactive shell is executed.  sudo
                   attempts to change to that user's home directory before
                   running the shell.  The command is run with an environment
                   similar to the one a user would receive at log in.  Note that
                   most shells behave differently when a command is specified as
                   compared to an interactive session; consult the shell's manual
                   for details.  The Command environment section in the
                   sudoers(5) manual documents how the -i option affects the
                   environment in which a command is run when the sudoers policy
                   is in use.
...

Open in new window

noci

sudo -s  can be useful as well (prevent ovewriting symbols from .bashrc).
sudo -s also allows accessing accounts without valid login environment like www-data etc.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
A A

ASKER
I dont know exactly what my last colleague did but how to recover that  as usual  if it is physically accessible or volume  can be mounted to another aws machine   known that, I dont have physical access to machine as it is in the AWS cloud.  
serialband

Do you have the actual root password so you can run su?  Is there another account that you can log into that can run sudo? Is there an ssh key in the root account?  Do you have access to AWS to boot the VM into single user or some other mode that can let you recover the VM?
A A

ASKER
 all accounts are configured to get to root by running sudo su  as I dont write root  password 
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
serialband

You only answered my first question.  What about the rest?
A A

ASKER
No I dont have root password all other accounts have same error  I can detach volume and attach it to another machine
ASKER CERTIFIED SOLUTION
serialband

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.