I have installed Ubuntu 22.04 in WSL2. I expect that the bash shall be started in the home directory that I find in /etc/passwd as
harper:x.1000:1000:,,,,:/home/harper:/bin/bash
But after starting wsl -d Ubuntu-22.04
the bash is somewhere in the Windows tree: /mnt/c/WINDOWS/system32
. I only need to issue the cd
command to get into home. And I could add this in a last line of ~/.bashrc. I already checked that this file is executed while starting bash.
But why do I see this strange behavior that the home directory is not the current directory?
Edit: I have also found a workaround. I can start wsl -d Ubuntu-22.04 --cd ~
. But this doesn't explain, why it's necessary.