1

I made a mistake giving wrong permissions on folders (chown I think on the wrong folder) when using wsl and ubuntu.

Now I have the following errors when I launch Ubuntu. I really don't know what to do:

sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: /usr/lib/sudo/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins

I tried some solutions provided on other answers but didn't solve my case.

What I don't understand is I uninstalled Ubuntu and still same error.

Is there a possibility to reset all on my laptop and reinstall everything ?

1 Answer 1

1

What I don't understand is I uninstalled Ubuntu and still same error.

If you uninstalled Ubuntu through Windows, what you installed and (presumably) reinstalled was not your distribution. That is just the "template" (rootfs) for the distribution that is created the first time you run the app. See this answer and/or this answer to understand more about that.

Is there a possibility to reset all on my laptop and reinstall everything ?

Sure, and that's probably the easiest path if you don't have any critical files in Ubuntu. Keep in mind that this is a destructive operation and all files in the Ubuntu distribution (but not Windows) will be removed.

From PowerShell:

wsl -l -v

# Confirm the distro name - Likely Ubuntu

wsl --unregister <distro_name>

Then simply rerun:

ubuntu.exe
# Or ubuntu2004.exe, ubuntu2204.exe, etc.

It will ask for the username and password that you want to use, similar to the way it did the first time you installed.

Then start as you would with a fresh installation:

sudo apt update && sudo apt upgrade -y

Now I have the following errors when I launch Ubuntu. I really don't know what to do

It looks like you may have done a recursive chown at the root level. In that case, it might be tough to recover all ownership exactly as-it-was. In general:

  • As far as I know, all files in /usr and /bin should be root-owned.

  • Files in /var will all be root-owned in a "default" installation, but additional programs (such as a mail or print server, which are rarely used under WSL) could mean user-owned files in /var.

  • /etc files are, in my experience, are usually owned by root, but additional services might install configuration files that are owned by a different user and/or group.

  • /home/<user> files should typically be owned by your user.

/root files should obviously be owned by root.

/tmp will vary, but (as they are all temp files anyway) it should be safe to remove anything left in there and start over.

Probably missed an import FHS directory somewhere in that list, but I'm going from memory at the moment.

7
  • Thank you. wsl -l -v gave: Ubuntu Running V2 and same for wsl. What files will I lost ? Do I will still have all the files on C: ? With Ubuntu and wsl I just do mnt and docker commands to create docker images and Dockerfile contain sudo commands. All the files I use are on C:\Users
    – jos97
    Feb 3, 2023 at 17:42
  • 1
    @jos97 All files of your Windows files will remain intact. Just the Ubuntu ext4 filessystem inside WSL will be removed. This will include files in /home/<username> for example. Files in `C:\Users` are fine. Feb 3, 2023 at 18:01
  • Thank you for your help ! Yes that is what I did I made a mistake on a command and gave recursive chown on lib folder. Do you think unregistring will solve my case about sudo ?
    – jos97
    Feb 3, 2023 at 18:08
  • 1
    @jos97 Yes, --unregister and then reinstalling the rootfs should reset the permissions and owners to the original, default state. Feb 3, 2023 at 20:16
  • 1
    @jos97 Yes, running ubuntu.exe or a variation mentioned above will install the rootfs after it has been removed. Feb 3, 2023 at 20:44

You must log in to answer this question.

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