0

So, I have 2 users in my Ubuntu WSL, and if I try to run code ., when the wsl opens in the main user as default it works fine, but when I switch to second user using su second_user, then running code . gives the following error:-

Command 'code' not found, did you mean:
  command 'tcode' from deb emboss (6.6.0+dfsg-11ubuntu1)
  command 'ode' from deb plotutils (2.6-11)
  command 'cde' from deb cde (0.1+git9-g551e54d-1.2)
  command 'node' from deb nodejs (12.22.9~dfsg-1ubuntu3)
  command 'cdde' from deb cdde (0.3.1-1build1)
Try: sudo apt install <deb name>

Then, if I go back to my previous user, then it stops working there as well, and gives the same error.

Vishnubly
  • 539
  • 1
  • 8
  • 17
  • 2
    Does this answer your question? [WSL2 after su the command code . doesn't work](https://stackoverflow.com/questions/70550829/wsl2-after-su-the-command-code-doesnt-work). Essentially [any method](https://superuser.com/q/1566022/1210833) of changing the default user will work, so if you'd like, you can add your (slightly different) solution to that question. – NotTheDr01ds Oct 08 '22 at 16:04
  • @NotTheDr01ds Sorry for the duplicate question, didn't find it. Thanks – Vishnubly Oct 08 '22 at 16:13
  • No worries! Duplicates can be tough to find sometimes. I only knew it was there because I had answered it! ;-). I've edited the original one to hopefully make it a bit easier to find in the future, too. – NotTheDr01ds Oct 08 '22 at 16:18

1 Answers1

0

So, a fix that I found for my situation was to change the default user of the WSL, by entering the following command in PowerShell of windows.

ubuntu config --default-user second_user

Where the general syntax of the command will be:-

<distro_name> config --default-user <username>
Vishnubly
  • 539
  • 1
  • 8
  • 17