0

I am trying use a command to install / update.

Here are the commands I would like to run:

sudo apt-get update
sudo apt install gnome-session gdm3
sudo apt-get upgrade
sudo apt-get install gnome-terminal

but I have two problems:

  1. I messed up with sudoers

  2. Permission denied (I guess from problem 1)


Sudoers is world writable:

Sudoers is world writable

Permision Denied:

Permision Denied

1
  • 1
    How did you "mess up" sudoers? What exactly did you do? In your second image, you are getting permission denied because you didn't use sudo. Also, if you need to post any other text or terminal output, please don't do this with images. Images of text are hard to read and impossible to work with. Instead, copy/paste into the body of your question and use code fences -- This will retain monospace formatting and ensure that we can work with the information you provide
    – Nmath
    Mar 30, 2022 at 18:01

1 Answer 1

1

If you messed up with sudoers (happened to me a lot of time, luckily only in container in docker ;) ), there is a possibility to repair it as root user.

While rebooting, you need to:

  • boot to the recovery mode,
  • mount the root / filesystem with write permissions mount –o rw,remount / and
  • repair the /etc/sudoers file with your preferred command line text editor, e.g. with vim or nano.

How to go to the recovery mode and mount the root / with write permissions is written e.g. here (there is also written how to change your password, if you have forgotten it (happened to me also a few times :D )).

Then just try to rewrite the sudoers file according to your wishes (always, but really always CHECK sudoers file with visudo -c on command line. The BEST would be before closing it!!! (if you are root, then it doesn't matter) It can save you a few minutes...)

Good luck and let us know, if you managed to do it :)

4
  • Hey, thanks for the response. I forgot to mention that i was using Ubuntu subsystem in Windows . Managed to change the password following the steps below: **Note remember your login username or go and find it (open ubuntu and see it displayed before DESKTOP...) before continuing In cmd of Windows-> ubuntu config --default-user root , Open ubuntu (opens as root): passwd -> type new password twice for confirmation -> (then while on root) login "type username hopefully you have read my note" -> type password. The commands i wanted to run, i runned them while being on the root.
    – xraise17
    Mar 31, 2022 at 7:11
  • To change again on becoming the root, use su " password". Now Mr.timmo & Mr.N math i don't know what exactly i have done to "mess up with sudoers", basically all i remember is using chmod while logged in as a user and giving access rights to everything for some reason something like that so i would be able to open files when moving outside the root directory i think.
    – xraise17
    Mar 31, 2022 at 7:19
  • @xraise17 what is a error message comming from command visudo -c? (Usually they have some useful message: E.g. sudoers must have to be in 0440 mode, owned by root user.
    – timmotej
    Apr 1, 2022 at 15:03
  • To change it: run commands chmod 440 /etc/sudoers;chown 0:0 /etc/sudoers
    – timmotej
    Apr 1, 2022 at 15:12

Not the answer you're looking for? Browse other questions tagged .