Score:0

How can I remove Windows Path from Ubuntu Path?

aw flag

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.

NotTheDr01ds avatar
vn flag
For anyone who comes across this in a search, please do *not* modify the registry (as done in the examples in the question) for this. There is a much easier and safer way to do it (see answers).
Score:1
vn flag

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
Score:0
aw flag

Solved overwriting the path

~/.profile export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

NotTheDr01ds avatar
vn flag
While it may "work", it's generally a bad idea to hard-code your entire path. First, while it may work *today*, future versions of the Ubuntu may change the default path, and you could override critical system functionality. Second, it limits your portability -- If you try to use a different distribution under WSL, or if you tried to move your profile to another system, the system may expect a different PATH. Best to let the OS manage the default PATH for you. Feel free to append to it, or modify it, but don't hard-code it entirely.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.