How can I remove Windows Path from Ubuntu Path?

How can I remove Windows Path from Ubuntu Path ?

~/.bashrc or other file does not contain it.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss = "AppendNtPath"=dword:00000000
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss{....} = "AppendNtPath"=dword:00000000

It has no effect.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss{GUID}\Flags

Change flags from 7 to 5, has reset my Ubuntu eliminating everything I had.


Solution 1:

If you want to prevent WSL from appending all Windows PATH elements to the Linux path, create (or edit) /etc/wsl.conf with these contents:

[interop]
appendWindowsPath=false

Then exit WSL, do a wsl --shutdown from PowerShell or CMD, and restart.

That said, this will make many useful features more difficult to use in WSL, since you will have to call the Windows commands with their full path. At least consider manually adding back in certain ones in your shell startup, such as:

  • /mnt/c/Windows/System32
  • /mnt/c/Windows
  • /mnt/c/Windows/System32/WindowsPowerShell/v1.0/
  • If you have VSCode installed, its path
  • If you have PowerShell Core installed, its path