vpoola88
vpoola88

Reputation: 3999

Switching from zsh to bash on OS X, and back again?

I'm learning to develop in Rails, and have discovered the power of zsh. However, for some of my other tasks, I wish to use normal bash.

Although they are the same, I just feel comfortable with the layout of bash in some situations.

How do I switch back and forth, or turn zsh on and off?

Upvotes: 351

Views: 467914

Answers (13)

Ruchira Randana
Ruchira Randana

Reputation: 4179

You can achieve this also via the UI by the following steps.

Step 1: Go to Preferences -> Users & Groups

Step 2: Select the user and press the unlock button and follow by entering the password

Step 3: Right click on the user and then select Advanced Options

Step 4: Select /bin/bash as the Login Shell

enter image description here

Note: You need to restart the shell to take this into effect.

Upvotes: 3

kushagra deep
kushagra deep

Reputation: 522

Follow the below steps:

chsh -s /bin/bash
Restart terminal
Check which shell is in use: echo $SHELL
source .profile

You are back with Bash!

Upvotes: 6

Aleks
Aleks

Reputation: 5320

For me, the solution was this:

Edit:

sudo vi /etc/passwd

Find your user, for me it was for example:

ubuntu:x:1000:1001::/home/ubuntu:/bin/sh

For you it might be:

ubuntu:x:1000:1001::/home/ubuntu:/bin/zsh

And change it to:

ubuntu:x:1000:1001::/home/ubuntu:/bin/bash

If you want bash to be defaul, or the line above if you want it to be zsh by default.

Upvotes: 0

wanghao
wanghao

Reputation: 3615

you can try chsh -s /bin/bash to set the bash as the default, or chsh -s /bin/zsh to set the zsh as the default.

Terminal will need a restart to take effect.

Upvotes: 257

Sarah A
Sarah A

Reputation: 1233

you can just type bash or if you always want to use bash:

on "iTerm2"

  • Go to preferences > Profiles > Command
  • Select "Command" from the dropdown
  • Type bash

Test by closing iTerm and open it again

Upvotes: 7

Kalhara Tennakoon
Kalhara Tennakoon

Reputation: 1482

In Mac OS Catalina default interactive shell is zsh. To change shell to zsh from bash:

chsh -s /bin/zsh

Then you need to enter your Mac password. Quit the terminal and reopen it. To check whether it's changed successfully to ssh, issue the following command.

echo $SHELL

If the result is /bin/zsh, your task is completed.

To change it back to bash, issue the following command on terminal.

chsh -s /bin/bash

Verify it again using echo $SHELL. Then result should be /bin/bash.

Upvotes: 8

Rahil
Rahil

Reputation: 277

if it is just a temporary switch

you can use exec as mentioned above, but for more of a permanent solution.

you can use chsh -s /bin/bash (to switch to bash) and chsh -s /bin/zsh (to switch to zsh)

Upvotes: 24

Paul Jurczyk
Paul Jurczyk

Reputation: 173

You should be able just to type bash into the terminal to switch to bash, and then type zsh to switch to zsh. Works for me at least.

Upvotes: 5

Rajani
Rajani

Reputation: 11

You can easily switch back to bash by using command "bye"

Upvotes: -8

as - if
as - if

Reputation: 3287

For Bash, try

chsh -s $(which bash)

For zsh, try

chsh -s $(which zsh)

Upvotes: 22

ljcusack
ljcusack

Reputation: 61

zsh has a builtin command emulate which can emulate different shells by setting the appropriate options, although csh will never be fully emulated.

emulate bash
perform commands
emulate -R zsh

The -R flag restores all the options to their default values for that shell.

See: zsh manual

Upvotes: 6

phil-ociraptor
phil-ociraptor

Reputation: 1081

I switch between zsh and bash somewhat frequently. For a while, I used to have to source my bash_profile every switch. Then I found out you can (typically) do

exec bash --login

or just

exec bash -l

Upvotes: 88

larsks
larsks

Reputation: 311516

You can just use exec to replace your current shell with a new shell:

Switch to bash:

exec bash

Switch to zsh:

exec zsh

This won't affect new terminal windows or anything, but it's convenient.

Upvotes: 672

Related Questions