Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use my Windows profile as Linux home #2108

Closed
gmmedia opened this issue May 15, 2017 · 12 comments
Closed

Use my Windows profile as Linux home #2108

gmmedia opened this issue May 15, 2017 · 12 comments

Comments

@gmmedia
Copy link

gmmedia commented May 15, 2017

Hello,
is it possible to use my Windows profile folder as my home directory in the BashOnWindows?
I have all my files there an see no sense of having a second home directory.

thanks
Jochen

@sunjoong
Copy link

sunjoong commented May 15, 2017

@gmmedia - No, you can't do it as I had heard; #449.

UPDATE: BUT!!! There is another bypass.

This was my /etc/passwd and /etc/shadow files;

SUNJOONG-DESKTOP ~ # cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
adm:x:3:4:adm:/var/adm:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/var/spool/news:/bin/false
uucp:x:10:14:uucp:/var/spool/uucp:/bin/false
operator:x:11:0:operator:/root:/sbin/nologin
portage:x:250:250:portage:/var/tmp/portage:/bin/false
nobody:x:65534:65534:nobody:/var/empty:/bin/false
sshd:x:22:22:added by portage for openssh:/var/empty:/sbin/nologin
man:x:13:15:added by portage for man-db:/usr/share/man:/sbin/nologin
messagebus:x:101:249:added by portage for dbus:/dev/null:/sbin/nologin
sunjoong:x:1000:1000::/home/sunjoong:/bin/bash
SUNJOONG-DESKTOP ~ # cat /etc/shadow
root:*:10770:0:::::
halt:*:9797:0:::::
operator:*:9797:0:::::
shutdown:*:9797:0:::::
sync:*:9797:0:::::
bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
news:*:9797:0:::::
uucp:*:9797:0:::::
portage:*:9797:0:::::
nobody:*:9797:0:::::
sshd:!:17269::::::
man:!:17269::::::
messagebus:!:17275::::::
sunjoong:$6$IAIXJ/Qapo66.L2$mpBojlEJcfwQibc4Gpj8GbtnWr99Z6iajhoJQrZIpIbDpKy810nlITl7t.NL2hTciL6KsqCRPDINUAoohY2/H/:17299:0:99999:7:::
SUNJOONG-DESKTOP ~ #

Close all bash terminal and open Windows PowerShell, and then command "lxrun /setdefaultuser root" and reopen bash; So I was root user and could append new user. I appened sunjoong1 user same to sunjoong user except home directory and uid;

SUNJOONG-DESKTOP ~ # cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
adm:x:3:4:adm:/var/adm:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/var/spool/news:/bin/false
uucp:x:10:14:uucp:/var/spool/uucp:/bin/false
operator:x:11:0:operator:/root:/sbin/nologin
portage:x:250:250:portage:/var/tmp/portage:/bin/false
nobody:x:65534:65534:nobody:/var/empty:/bin/false
sshd:x:22:22:added by portage for openssh:/var/empty:/sbin/nologin
man:x:13:15:added by portage for man-db:/usr/share/man:/sbin/nologin
messagebus:x:101:249:added by portage for dbus:/dev/null:/sbin/nologin
sunjoong:x:1000:1000::/home/sunjoong:/bin/bash
sunjoong1:x:1001:1000::/mnt/c/Users/sunjoong/Desktop:/bin/bash
SUNJOONG-DESKTOP ~ # cat /etc/shadow
root:*:10770:0:::::
halt:*:9797:0:::::
operator:*:9797:0:::::
shutdown:*:9797:0:::::
sync:*:9797:0:::::
bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
news:*:9797:0:::::
uucp:*:9797:0:::::
portage:*:9797:0:::::
nobody:*:9797:0:::::
sshd:!:17269::::::
man:!:17269::::::
messagebus:!:17275::::::
sunjoong:$6$IAIXJ/Qapo66.L2$mpBojlEJcfwQibc4Gpj8GbtnWr99Z6iajhoJQrZIpIbDpKy810nlITl7t.NL2hTciL6KsqCRPDINUAoohY2/H/:17299:0:99999:7:::
sunjoong1:$6$IAIXJ/Qapo66.L2$mpBojlEJcfwQibc4Gpj8GbtnWr99Z6iajhoJQrZIpIbDpKy810nlITl7t.NL2hTciL6KsqCRPDINUAoohY2/H/:17299:0:99999:7:::
SUNJOONG-DESKTOP ~ #

I used editor but you could use "useradd" to append new user or just simply use echo redirection method, I think. Close all bash terminal and open Windows PowerShell, and then command "lxrun /setdefaultuser sunjoong1" and reopen bash; sunjoong1 is my new user name in here. The home directory of sunjoong1 is C:\Users\sunjoong\Desktop, i.e., %USERPROFILE%\Desktop directory.

@fpqc
Copy link

fpqc commented May 15, 2017

This can screw up things that rely on linux semantics and permissions. Also, your profile will be world-readable, writable, and executable to all Lx users associated with your windows user's Linux instance.

@gmmedia
Copy link
Author

gmmedia commented May 15, 2017

Thank you for your answers. I have no other users on my computer, so the file permissions are not really a problem.
But I think Microsoft have to come with a supported feature for that.

@sunjoong
Copy link

@gmmedia - Well... That's somehow a cheat, not a standard, and will never be a regular feature because so many side-effects may occur, I think. @fpqc mentioned permission issue. I'd like to point other one, #2025; At this point, you might not use make utility because of incorrect timestamp. Someday, MS could fix that, but there will be so many traps we don't know yet.

@aseering
Copy link
Contributor

aseering commented May 16, 2017

@gmmedia -- regarding permissions, for what it's worth, even if you don't think you need file permissions, your software may beg to differ :-) For example, ssh will refuse to use keys that are world-readable, even on a single-user machine. So, ssh keys won't work if you switch your home directory to DrvFs.

Also, note that Linux uses file permissions to determine whether a file is an executable program. That functionality doesn't work either, in DrvFs right now. If you (or tools that you use) try to install Linux programs within your home directory, the installation may fail and/or have weird side effects.

@gmmedia
Copy link
Author

gmmedia commented May 16, 2017

Oh, I of course need ssh. I see now, that not a doable way.
I have to life with the two home dirs.

@sunjoong
Copy link

@gmmedia - You said "I have all my files there" and... that was just why you wanted to "Use Windows profile as Linux home"... If so, to use https://github.com/goreliu/wsl-terminal might be a way, I think; In
the Usage section of wsl-terminal Readme.md, there is written as "3. Run tools/add-open-wsl-here-menu.js to add a Open WSL Here context menu to explorer.exe". That means... you can open bash terminal by mouse right button after openning folder what you want with windows file explorer.

@gmmedia
Copy link
Author

gmmedia commented May 16, 2017

I like the terminal that comes with Windows.
So I have used that doku to add the the Bash to my Explorers context menu: https://www.howtogeek.com/270810/how-to-quickly-launch-a-bash-shell-from-windows-10s-file-explorer/

@fpqc
Copy link

fpqc commented May 16, 2017

@gmmedia easiest thing to do is

ln -s ~/files /mnt/c/Users/%yourwindowsuser%

so you can cd files and get to your windows user profile directory

@gmmedia
Copy link
Author

gmmedia commented May 16, 2017

Sure, thats an easy way to cd to my files.
Will will also do backup of my home directory to Onedrive

@JoBrad
Copy link

JoBrad commented May 16, 2017

I have certain directories (like .ssh) symlinked to my Windows user home. But this seems like a good way to screw up both the Linux and Windows user accounts. I value my ability to simply blow the Linux distro away and re-install with minimal effort.

@therealkenc
Copy link
Collaborator

This scenario is supported in the 1803 April Update (17063) via the metadata mount option. Ref #2612.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants