1

Everywhere I see advice to run WSL commands as

wsl --user root linuxcommand

however I only get error saying

/bin/bash: --: invalid option

Why does my WSL pick up "--"?

wsl linuxcommand 

works just fine, except when I need to elevate privileges and I get permission denied, for which I would seem to need "--user root" switch.

1 Answers1

1

Everywhere I see advice to run WSL commands as …, however, I only get error saying that -- was an invalid option. I am running Windows 10 version 1803.

The feature you are attempting to use is only supported on Windows 10 version 1903.

Starting with Windows 10 build 18342 (19H1) and Windows 10 build 18836 (20H1), Microsoft added some new commands that will give you more functionality when using wsl.exe. The commands that existed inside of wslconfig.exe have been added to wsl.exe to allow you to configure your distros more easily.

In order to set the default user you would have to use the command ubuntu config --default-user root if you were running a WSL instance on Windows 10 version 1803.

WSL Config (wslconfig.exe) is a command-line tool for managing Linux distributions running on the Windows Subsystem for Linux (WSL). It lets you list available distributions, set a default distribution, and uninstall distributions. While WSL Config is helpful for settings that span or coordinate distributions, each Linux distribution independently manages its own configurations. To see distribution-specific commands, run [distro.exe] /?. For example ubuntu /?.

Source:

Ramhound
  • 44,080