0

I would like to change the home directory when launching UBUNTU via Windows Terminal but I don't seem to find where the /home/userdirectory is located in windows in order to change it. In the screenshot below you can see that the Starting directory is the %USERPROFILE% which redirects me to user@Machine:/mnt/c/Users/user

enter image description here

I wish to change this entry point to /home/user but I do not know where it is located in the Windows Machine in order to point it there.

2
  • The location of your WSL files is discussed at great length and depth at superuser.com/questions/1185033/…. I don't quite understand where you want to move your home directory, though, and why. May 3, 2021 at 11:58
  • The entry point is the /mnt/c/Users/user. I wish to make it point at /home/usr
    – ex1led
    May 3, 2021 at 11:59

1 Answer 1

1

There are several ways to set your home directory when starting up a WSL session through Windows Terminal. Most of them involve simple options to the wsl.exe command, which is the recommended method of launching WSL in most cases:

  • The easiest option for what you say you want (in the comments) is to just change the "Command Line" in the Windows Terminal settings to be wsl ~. That's a (currently) undocumented option to the wsl command that always starts in the user's home directory.

  • Alternatively, there is another (currently) undocumented option wsl --cd to set an arbitrary directory. That one takes a Windows directory path, not a Linux path, so you'll need to know that WSL files can be accessed via \\wsl$\<distroname>\... in Windows. For instance, if the name of your instance is "Ubuntu" (the default), then setting the Command Line for this profile in Windows Terminal to be wsl --cd \\wsl$\Ubuntu\home\username would start in /home/username. This is only really useful if you want a directory other than home, since the first option above is easier for home.

  • Finally, using that same information about \\wsl$\<distroname>, you can probably figure out that changing the Windows Terminal "Starting directory" to \\wsl$\Ubuntu\home\username would have the desired effect as well. This would cause Windows Terminal to first change the directory, and then launch the WSL process in that directory. Note that using either of the previous two options overrides this, because WSL will change/set the directory after Windows Terminal does so.

1
  • How I eventually solved it, was by doing the following. After entering my ~ (home) directory from WSL Ubuntu, I invoked the win explorer as explorer.exe . and copied/pasted the path as a starting directory. Your solution worked fine as well.
    – ex1led
    May 25, 2021 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .