Use Windows 10 home folder as WSL Ubuntu shell home directory
As I moved on professionally and started to develop dotnet applications for Windows I had to switch my OS from MacOSX to Windows (I still use MacOSX for other stuff). So this change forced me to adapt to a new environment – or better, to go back to a previous one – anyway, I still miss my shell and all it’s features.
Fortunately, Windows 10 can run a WSL and I can use the Ubuntu shell as my main one. If you use a shell regularly you probably often use the commands: cd or the shortcut ~/Downloads for example, and that is a problem because the WSL Shell home is located, in my case, at /home/walter and my user (windows) home is at C:/Users/Walter (/mnt/c/Users/Walter) so: how can I change my default home shell so I can use the home shell directory as the same as the OS home directory?
Quite easy, open a new shell and type:
sudo vim /etc/passwd
Search for your username, must look something like that:
walter:x:1000:1000:,,,:/home/walter:/bin/bash
and change your home directory /home/walter to the one that you want to use, in my case I changed it to /mnt/c/Users/Walter
walter:x:1000:1000:,,,:/mnt/c/Users/Walter:/bin/bash
save and exit vim.
You can copy your user definition
cp /home/walter/.bash* /home/walter/.profile /mnt/c/Users/Walter/
Close and re-open the shell and you’re good to go.