Changing home directory of user on Windows Subsystem for Linux
Changing the home directory with WSL is done the same way as in Linux:
- Enter bash
- Type the command
sudo vim /etc/passwd
- Find your account's line, which might look like:
harry:x:1000:1000:"",,,:/home/harry:/bin/bash
- Change the home directory, which above is
/home/harry
, to the new directory, using WSL notation (If you want to set Windows directory as home directory, you need to prepend it with/mnt/
, like/mnt/c
for C:/,/mnt/d
for D:/, etc) - Save the file and exit vim by typing
:wq
and press Enter - Exit bash and re-launch it
- To test, use the commands:
cd ~
pwd
Let me know if you need more information.