Steve Hindmarch

A new site for my ramblings

View the Project on GitHub

Break Into An Instance As Root

Home Up

From time to time you might come across a terminal instance that when launched has a fault with running sudo. So as you do not have the root password, how do you get in as root?

As this is being run by WSL, not docker, you need to use WSL commands.

  1. Close any running terminals.
  2. Open a windows command line terminal.
  3. Check the name of your instance by running wsl --list.
  4. Run a shell as root using wsl --user root --distribution mydistro.
  5. Make your changes and exit.

For example, make sure sudo is installed and your default user has full access.

> wsl --user root --distribution RockyLinux-9-Base

# dnf install sudo
# usermod -aG wheel myuser
# exit

Home | Up