In WSL2 with the Remote - WSL plugin for Visual Code if I do code . Visual Code open on the specified folder, but if I change user with su, the same command output:
Command 'code' not found, did you mean:
...
In WSL2 with the Remote - WSL plugin for Visual Code if I do code . Visual Code open on the specified folder, but if I change user with su, the same command output:
Command 'code' not found, did you mean:
...
You seem to be running into this issue, where the Remote extension always uses the default user.
While no solution here is ideal, there are (at least) three options, depending on your exact use-case:
Temporarily change the default user:
You'll need to sudo -e /etc/wsl.conf and add:
[user]
default=other_username
Then wsl --terminate <distro> (from PowerShell, CMD, or the Start menu), then restart.
Use two different WSL instances with different default users in each one.
Possibly, give your default user permissions to whatever files you are trying to edit for the other user.