How do I switch from an unknown shell to bash?

  • I was surprised that I didn't find this question already on the site. So, today $ came up after I logged in as a new user. This was unexpected because my main user's prompt starts with [email protected]:~$.

    So, how do I switch from this other shell to bash?

    Just because `$` came up rather than `[email protected]:~$` doesn't mean it wasn't bash. The exact formatting of the prompt is set by the PS1 variable, which can be set up or customized differently for different users.

    @mouche Re: @frabjous `echo $SHELL` to find out what your current shell is.

    @mouche @frabjous and beginning with a $ is actually common for bash, some non bash shells like zsh use the % out of the box, I believe other shells use other things.

    @xeno it was /bin/sh and something I tried to do didn't work like it would in BASH.

    @mouche being `/bin/sh` often doesn't mean much that's usually a symlink to something else. I'd type `ls -l /bin/sh` to see what it's a symlink to. In some cases being a symlink to something changes its behavior, I don't think bash is that way.

    Oh, I never knew @xenoterracide. On my machine, `/bin/sh` is a symlink to `/bin/dash`.

    @xenoterracide - Using `bash` as `/bin/sh` *disables* many bash features (it goes into POSIX compliance mode).

  • Kevin M

    Kevin M Correct answer

    10 years ago

    Assuming the unknown shell supports running an absolute command, you could try: /bin/bash

    To change the default shell, I would use chsh(1). Sample usage: chsh -s /bin/bash $USER

    Does chsh permanently change the shell or just for the current session?

    @mouche Permanently; it changes your entry in `/etc/passwd`

    @mouche, `chsh(1)` will only allow to change to a shell that is listed in `/etc/shells` (and is available, presumably). `chsh -l` lists the alternatives. Be careful, some (like `nologin`) are defined for accounts that should never be used to login (nice way to lock yourself out), there might be local additions for special uses.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM