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

Can't change default shell #846

Closed
liamness opened this Issue Aug 10, 2016 · 24 comments

Comments

Projects
None yet
@liamness

liamness commented Aug 10, 2016

  • A brief description
    Would like to use zsh instead of bash, mainly because of the oh-my-zsh scripts and all the lovely things they do.
  • Expected results
    Opening bash.exe after changing default shell to zsh opens zsh instead of bash.
  • Actual results (with terminal output if applicable)
    zsh was running just fine, until I closed and opened bash.exe again, when it was running bash once more.
  • Your Windows build number
    Sorry, don't know. Just installed the update this evening though.
  • Steps / commands required to reproduce the error
    • sudo apt-get install git zsh
    • sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    • Quit bash and open again.
    • Also tried running chsh -s /usr/bin/zsh but that didn't seem to make much difference.
@EricGT

This comment has been minimized.

Show comment
Hide comment
@EricGT

EricGT Aug 10, 2016

A quick way to get build number is to open a command prompt. It is at the top.

Microsoft Windows [Version 10.0.14393]

EricGT commented Aug 10, 2016

A quick way to get build number is to open a command prompt. It is at the top.

Microsoft Windows [Version 10.0.14393]

@benhillis

This comment has been minimized.

Show comment
Hide comment
@benhillis

benhillis Aug 10, 2016

Member

As a workaround I'd suggest the following:

chsh -s /usr/bin/zsh

Create a Windows shortcut to \Windows\System32\bash.exe -c "/usr/bin/zsh"

Member

benhillis commented Aug 10, 2016

As a workaround I'd suggest the following:

chsh -s /usr/bin/zsh

Create a Windows shortcut to \Windows\System32\bash.exe -c "/usr/bin/zsh"

@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 10, 2016

zsh installs to /bin/zsh guys

fpqc commented Aug 10, 2016

zsh installs to /bin/zsh guys

@benhillis

This comment has been minimized.

Show comment
Hide comment
@benhillis

benhillis Aug 10, 2016

Member

Interesting. There's also a /usr/bin/zsh on my box.

Member

benhillis commented Aug 10, 2016

Interesting. There's also a /usr/bin/zsh on my box.

@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 10, 2016

¯\_(ツ)_/¯ Symlinked?

fpqc commented Aug 10, 2016

¯\_(ツ)_/¯ Symlinked?

@hrlngrv

This comment has been minimized.

Show comment
Hide comment
@hrlngrv

hrlngrv Aug 10, 2016

The bash.exe Windows command which launches the Linux subsystem apparently just launches /bin/bash. It's not a true login, so it doesn't access /etc/passwd, even using bash.exe's --login command line switch. OTOH, it's possible to use -c zsh to run zsh or -c login to log into the Linux subsystem, and that does access /etc/passwd and the default shell setting.

hrlngrv commented Aug 10, 2016

The bash.exe Windows command which launches the Linux subsystem apparently just launches /bin/bash. It's not a true login, so it doesn't access /etc/passwd, even using bash.exe's --login command line switch. OTOH, it's possible to use -c zsh to run zsh or -c login to log into the Linux subsystem, and that does access /etc/passwd and the default shell setting.

@benhillis

This comment has been minimized.

Show comment
Hide comment
@benhillis

benhillis Aug 10, 2016

Member

@fpqc looks like they are both symlinks to the same file.

benhill@BENHILL-X1:~$ ll /bin/zsh
lrwxrwxrwx 1 root root 21 Aug  9 17:25 /bin/zsh -> /etc/alternatives/zsh*
benhill@BENHILL-X1:~$ ll /etc/alternatives/zsh
lrwxrwxrwx 1 root root 9 Aug  9 17:25 /etc/alternatives/zsh -> /bin/zsh5*
benhill@BENHILL-X1:~$ ll /bin/zsh5
-rwxr-xr-x 1 root root 692928 Oct 10  2013 /bin/zsh5*
benhill@BENHILL-X1:~$ ll /usr/bin/zsh
lrwxrwxrwx 1 root root 28 Aug  9 17:25 /usr/bin/zsh -> /etc/alternatives/zsh-usrbin*
benhill@BENHILL-X1:~$ ll /etc/alternatives/zsh-usrbin
lrwxrwxrwx 1 root root 9 Aug  9 17:25 /etc/alternatives/zsh-usrbin -> /bin/zsh5*

@hrlngrv You are mostly correct. Our /init daemon does access /etc/passwd for some information, just not the default shell. The reasoning behind this is we might not be compatible with all shells (yet) and I didn't want users to get into a state where they couldn't launch a shell. Also it's a little funny to run bash.exe and have zsh pop up. This is definitely something we're looking at more in the future.

Member

benhillis commented Aug 10, 2016

@fpqc looks like they are both symlinks to the same file.

benhill@BENHILL-X1:~$ ll /bin/zsh
lrwxrwxrwx 1 root root 21 Aug  9 17:25 /bin/zsh -> /etc/alternatives/zsh*
benhill@BENHILL-X1:~$ ll /etc/alternatives/zsh
lrwxrwxrwx 1 root root 9 Aug  9 17:25 /etc/alternatives/zsh -> /bin/zsh5*
benhill@BENHILL-X1:~$ ll /bin/zsh5
-rwxr-xr-x 1 root root 692928 Oct 10  2013 /bin/zsh5*
benhill@BENHILL-X1:~$ ll /usr/bin/zsh
lrwxrwxrwx 1 root root 28 Aug  9 17:25 /usr/bin/zsh -> /etc/alternatives/zsh-usrbin*
benhill@BENHILL-X1:~$ ll /etc/alternatives/zsh-usrbin
lrwxrwxrwx 1 root root 9 Aug  9 17:25 /etc/alternatives/zsh-usrbin -> /bin/zsh5*

@hrlngrv You are mostly correct. Our /init daemon does access /etc/passwd for some information, just not the default shell. The reasoning behind this is we might not be compatible with all shells (yet) and I didn't want users to get into a state where they couldn't launch a shell. Also it's a little funny to run bash.exe and have zsh pop up. This is definitely something we're looking at more in the future.

@hrlngrv

This comment has been minimized.

Show comment
Hide comment
@hrlngrv

hrlngrv Aug 10, 2016

@benhillis I'm curious what information init pulls from /etc/passwd. bash.exe always starts as user root, uses the working directory from which it was run (console) or given in the .lnk shortcut (GUI), and doesn't run the chosen default shell. Is the info that user root has user number 0 and group number 0? There's nothing much else in /etc/passwd.

As for funniness, you could always rename bash.exe to WSL.EXE, or leave bash.exe always to run /bin/bash and add WSL.EXE to run the selected default shell.

bash may be the most popular of shells, but long-time zsh and csh (and maybe also ksh) users want to use their favorites.

hrlngrv commented Aug 10, 2016

@benhillis I'm curious what information init pulls from /etc/passwd. bash.exe always starts as user root, uses the working directory from which it was run (console) or given in the .lnk shortcut (GUI), and doesn't run the chosen default shell. Is the info that user root has user number 0 and group number 0? There's nothing much else in /etc/passwd.

As for funniness, you could always rename bash.exe to WSL.EXE, or leave bash.exe always to run /bin/bash and add WSL.EXE to run the selected default shell.

bash may be the most popular of shells, but long-time zsh and csh (and maybe also ksh) users want to use their favorites.

@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 10, 2016

@hrlngrv I only use bash for one thing, to install zsh =)

fpqc commented Aug 10, 2016

@hrlngrv I only use bash for one thing, to install zsh =)

@Fengxq2014

This comment has been minimized.

Show comment
Hide comment
@Fengxq2014

Fengxq2014 commented Aug 11, 2016

I think this will help you How to Use Zsh (or Another Shell) in Windows 10

@huyinjie

This comment has been minimized.

Show comment
Hide comment
@huyinjie

huyinjie Aug 18, 2016

@Fengxq2014 Successful , Thanks!!

huyinjie commented Aug 18, 2016

@Fengxq2014 Successful , Thanks!!

@lapo-luchini

This comment has been minimized.

Show comment
Hide comment
@lapo-luchini

lapo-luchini Aug 27, 2016

A normal -c zsh symlink opened up in the wrong directory to me, but I managed using this (note the tilde):

C:\Windows\System32\bash.exe ~ -c /bin/zsh

lapo-luchini commented Aug 27, 2016

A normal -c zsh symlink opened up in the wrong directory to me, but I managed using this (note the tilde):

C:\Windows\System32\bash.exe ~ -c /bin/zsh
@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 27, 2016

@lapo-luchini Yeah, that was added a while ago for exactly the reason you mentioned.

fpqc commented Aug 27, 2016

@lapo-luchini Yeah, that was added a while ago for exactly the reason you mentioned.

@lapo-luchini

This comment has been minimized.

Show comment
Hide comment
@lapo-luchini

lapo-luchini Aug 27, 2016

I noticed is still not a complete work-around, e.g. the environment contains SHELL=/bin/bash and thus executing tmux it uses bash as a default shell.

lapo-luchini commented Aug 27, 2016

I noticed is still not a complete work-around, e.g. the environment contains SHELL=/bin/bash and thus executing tmux it uses bash as a default shell.

@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 27, 2016

@lapo-luchini Yeah, but you can fix that in your .tmux.conf. It's unfortunate, but I don't know how to fix it.

One option is to uninstall bash, then symlink /bin/bash to zsh, maybe? Maybe don't do this, could be a bad idea on a non-test install.

fpqc commented Aug 27, 2016

@lapo-luchini Yeah, but you can fix that in your .tmux.conf. It's unfortunate, but I don't know how to fix it.

One option is to uninstall bash, then symlink /bin/bash to zsh, maybe? Maybe don't do this, could be a bad idea on a non-test install.

@benhillis

This comment has been minimized.

Show comment
Hide comment
@benhillis

benhillis May 11, 2017

Member

The most recent Windows Insider build has added wsl.exe which performs two functions:

  1. When run without arguments, it will launch your default user's default shell (which is configurable via the chsh command).
  2. When run with arguments, it is an easy way to run a specific Linux binary (wsl.exe ls).

Otherwise, it behaves exactly like bash.exe

Member

benhillis commented May 11, 2017

The most recent Windows Insider build has added wsl.exe which performs two functions:

  1. When run without arguments, it will launch your default user's default shell (which is configurable via the chsh command).
  2. When run with arguments, it is an easy way to run a specific Linux binary (wsl.exe ls).

Otherwise, it behaves exactly like bash.exe

@sunilmut sunilmut closed this Jun 26, 2017

@athrunsun

This comment has been minimized.

Show comment
Hide comment
@athrunsun

athrunsun Aug 25, 2017

@hrlngrv I'm sorry but how should I add WSL.EXE?

Edited: Sorry, should've known WSL stands for Windows Subsystem for Linux.

Renaming from bash.exe -> wsl.exe doesn't work for me. Why would renaming even work?

athrunsun commented Aug 25, 2017

@hrlngrv I'm sorry but how should I add WSL.EXE?

Edited: Sorry, should've known WSL stands for Windows Subsystem for Linux.

Renaming from bash.exe -> wsl.exe doesn't work for me. Why would renaming even work?

@athrunsun

This comment has been minimized.

Show comment
Hide comment
@athrunsun

athrunsun Aug 25, 2017

@benhillis If I am on an older version of Windows 10, Version 1703 (Updated March 2017), am I able to get the newly added wsl.exe by reinstalling "Bash on Ubuntu on Windows" in Windows Store?

athrunsun commented Aug 25, 2017

@benhillis If I am on an older version of Windows 10, Version 1703 (Updated March 2017), am I able to get the newly added wsl.exe by reinstalling "Bash on Ubuntu on Windows" in Windows Store?

@fpqc

This comment has been minimized.

Show comment
Hide comment
@fpqc

fpqc Aug 25, 2017

@athrunsun oh my god I can't believe you did that. Don't ever edit files in C:\Windows!!!

The 'newly added wsl.exe' was added in an insider build after 1703. Just search for the Windows Insider Program, register your Microsoft account and enable fast ring updates.

fpqc commented Aug 25, 2017

@athrunsun oh my god I can't believe you did that. Don't ever edit files in C:\Windows!!!

The 'newly added wsl.exe' was added in an insider build after 1703. Just search for the Windows Insider Program, register your Microsoft account and enable fast ring updates.

@kiamlaluno

This comment has been minimized.

Show comment
Hide comment
@kiamlaluno

kiamlaluno Sep 3, 2017

I have a wsl.exe file in C:\Windows\System32. If I create a link to that file, and I place the link in C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs, clicking that link doesn't do anything, except opening a window that quickly gets closed.

kiamlaluno commented Sep 3, 2017

I have a wsl.exe file in C:\Windows\System32. If I create a link to that file, and I place the link in C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs, clicking that link doesn't do anything, except opening a window that quickly gets closed.

@kiamlaluno

This comment has been minimized.

Show comment
Hide comment
@kiamlaluno

kiamlaluno Sep 3, 2017

The default shell was not correctly set. Actually, it was set to the old shell I then removed. I edited the /etc/passwd file, and the wsl.exe link now works.

kiamlaluno commented Sep 3, 2017

The default shell was not correctly set. Actually, it was set to the old shell I then removed. I edited the /etc/passwd file, and the wsl.exe link now works.

@athrunsun

This comment has been minimized.

Show comment
Hide comment
@athrunsun

athrunsun Sep 4, 2017

@fpqc OK, thanks for your update. I think it does no harm to my system since I was renaming a copy of the original bash.exe

athrunsun commented Sep 4, 2017

@fpqc OK, thanks for your update. I think it does no harm to my system since I was renaming a copy of the original bash.exe

@eberkund

This comment has been minimized.

Show comment
Hide comment
@eberkund

eberkund Sep 30, 2017

Is wsl.exe available in the stable builds yet?

eberkund commented Sep 30, 2017

Is wsl.exe available in the stable builds yet?

@kiamlaluno

This comment has been minimized.

Show comment
Hide comment
@kiamlaluno

kiamlaluno Oct 1, 2017

@eberkund I think it is not available, so far. Maybe Fall Creators Update will have it.

kiamlaluno commented Oct 1, 2017

@eberkund I think it is not available, so far. Maybe Fall Creators Update will have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment