1

As above, I want to by default open Ubuntu 22.04.1 (in WSL) through Microsoft Terminal in my Windows home directory C:\Users\\<name\>.

I've tried entering the default path as C:\\Users\\\<name> and as /mnt/C/Users/\<name>, as well as editing the JSON file directly, but each time I get the error:

Could not access starting directory _"\<choice of directory\>"_

... on start up. How would I get WSL to open in the Windows home directory?

1
  • I've found a work-around. Add the line cd /mnt/c/Users/\<name> to the end of .bashrc (I'm aware that this might not be the correct file to edit, but at least .bashrc is executed at every login, so I do end up in the correct directory)
    – user36196
    Commented Nov 19, 2022 at 23:01

1 Answer 1

2

Edit the profile in Windows Terminal and change the command-line to be wsl --cd C:\Users\%username%. The --cd argument can handle either Windows paths or Linux paths inside the WSL distribution.

The %username% is the CMD variable for the username, since Windows still uses the old (pre-PowerShell) variable style when launching applications. You could, of course, hardcode it as well.

Keep in mind that file access under WSL2 is currently still much slower on Windows drives.

1
  • I'm aware it may be slower accessing Windows drives from the WSL command line, but I'm more familiar with the *sh command lines than Windows CMD or PowerShell, so I'm happy to take the performance hit for the limited number of things I do with it
    – user36196
    Commented Nov 21, 2022 at 11:15

You must log in to answer this question.

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