I have a path I want to use as a home directory in WSL, but it's also path that has spaces in it.

I've tried escaping the spaces with slashes, and I've tried using single and double quotes with just spaces in the file, but it sets me at the root directory, instead of my home directory, it seems I cannot specify a path with spaces in it within /etc/passwd.

Is there some other way to make this work?

  • 1
    What happens when you just use a plain space? What errors occur, in what situations? – Jeff Schaller Sep 18 '19 at 13:13
  • 1
    I assumed you had already tried it! I was curious what was breaking as a result... – Jeff Schaller Sep 18 '19 at 13:40
  • 1
    I'll put an answer for now, but I'm curious what's really tripping up the situation. – Jeff Schaller Sep 18 '19 at 13:50
  • 1
    What do you mean by "it never seems to work"? – roaima Sep 18 '19 at 13:53
  • 1
    I meant that one possible failure scenario would be: source $HOME/.bashrc, when it should be source "$HOME"/.bashrc. Perhaps it's worth a separate question with the steps to reproduce it. – Jeff Schaller Sep 18 '19 at 13:54

Simply use a space:

username:x:42:42:Jeff Schaller:/home/spaces here/username:/bin/bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.