Changing home directory of user on Windows Subsystem for Linux

Changing the home directory with WSL is done the same way as in Linux:

  1. Enter bash
  2. Type the command sudo vim /etc/passwd
  3. Find your account's line, which might look like:
    harry:x:1000:1000:"",,,:/home/harry:/bin/bash
  4. 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)
  5. Save the file and exit vim by typing :wq and press Enter
  6. Exit bash and re-launch it
  7. To test, use the commands:
    cd ~
    pwd

Let me know if you need more information.