Possible side effects of changing shell from zsh to bash

87,498

Solution 1

Changing your shell, via sudo chsh --shell=/bin/bash $USER will change the shell field in /etc/passwd. This value is only consulted at login time, when the system has no idea of which shell to use for you.

Running processes, whether started by zsh, bash apache or evil_overlord's_program won't be affected

Solution 2

Answer from the Stack Overflow (switching from zsh to bash):

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.

Solution 3

Open your terminal and use the following command:

chsh -s $(which bash)

Solution 4

On Mac OS Catalina

  1. Change to zsh:

    chsh -s /bin/zsh
    
  2. Change to bash:

    chsh -s /bin/bash
    
Share:
87,498

Related videos on Youtube

JohnMerlino
Author by

JohnMerlino

Looking to master Trigonometry and Calculus and an interest in Ruby and JavaScript programming languages. I only use Linux (in particular Ubuntu Desktop) and Android. I like to write as well.

Updated on September 18, 2022

Comments

  • JohnMerlino
    JohnMerlino over 1 year

    My web server was tampered by someone who was using zsh shell. I feel more comfortable using bash shell, as that's the defaults that come with Ubuntu and OS X (the two main operating systems I use). But this questions is focused on Ubuntu server.

    I have 4 websites running on this web server, I use byobu, I use tmux, I use ruby/ruby on rails, node.js, Apache, a few daemons. If I switch the current root shell from zsh to bash, could there be any negative side effects that might result from this switch? For example, will processes be killed because their parent process (the shell) has been switched?

    • Admin
      Admin over 10 years
      Are you asking about the consequences of the change (which are none, I'm using zsh right now and can switch to bash whenever I like) or are you asking about how to effectively change the shell?
    • Admin
      Admin over 10 years
      @Braiam I am nervous about the consequences of the change. If there are no consequences, then I will change. I was just thinking that the shell was a parent process to some of these daemons like apache, and if I was to switch out of it, that it would kill the apache process. But I guess I am wrong.
  • JohnMerlino
    JohnMerlino about 10 years
    I assume this is the equivalent of chsh -s /bin/bash
  • JohnMerlino
    JohnMerlino about 10 years
    Isn't the shell the parent process of other processes running in it, or just the controlling terminal (and not the shell) would be considered the parent process?
  • goo
    goo about 10 years
    The login program runs in a process, like everything. When it lets you in, it creates another process with your UID, etc, and runs /bin/bash (from /etc/passwd). The bash shell reads from STDIN (set up by login), and will fork/exec non-builtin commands, wait for them to terminate, and loop for more commands. The idea of "controlling terminal" is not useful in Unix/Linux.
  • ryanjdillon
    ryanjdillon over 9 years
    which bash would give the absolute path of bash, so it would be the same if /bin/bash is where bash was located.
  • ses
    ses over 6 years
    did not work. still : echo $SHELL /usr/bin/zsh
  • Pablo Bianchi
    Pablo Bianchi over 3 years
    @ses $SHELL gives you the default login shell. $0 gives you the current shell (the name of the running process) and $$ is the process ID (PID) of the script itself. Try ps $$ or echo $0