I'm using Centos 6 and after reading about different shells and dash implementasion as sh replacement in Debian, Ubuntu and Fedora, made up my mind to replace sh with dash as the script shell in Centos.

I have no idea how to see if this is already done, because I have both sh and dash in my system, so how do I know which is my default script shell?

4 Answers 4


You can determine your default shell with the following command:

grep -- "$LOGNAME" /etc/passwd | awk -F":" '{print $7}'

In my machine, sh is a link to dash, try:

ls -l "$(which sh)"
  • Wow, thank you, in my machine sh is a link to bash.lrwxrwxrwx. 1 root root 4 mar 9 22:42 /bin/sh -> bash May 20, 2013 at 9:48

The "script shell" is not the login shell. It is whatever is running as /bin/sh. Note that many Bourne shell derivatives (i.e., shs like bash and dash, and probably also the Korn shell lookalikes) behave differently when called as sh

  • 1
    Good advice; I don't think dash has a life outside of serving as sh, so its behavior probably doesn't change when invoked as sh (do tell me if you know that it does).
    – mklement0
    May 22, 2015 at 13:01

On Centos (and ever in other linuxes & unices) you can know what is the shell you are using doing this commands:

$ id
uid=501(john1) gid=1000(groupname1) ....

that tell you that you are using user john1 and then:

$ grep john1 /etc/passwd

the last string afther / tell you what is your login shell (in this example is `/bin/bash')

To change your login shell you can edit (as user root) this string into passwd but be carefull to do not change anythig else.

If you have a Graphical Interface installed (like GNOME or KDE) there are other graphical tools to change this settings.

  • If you want to change your shell, use chsh.
    – schaiba
    May 20, 2013 at 10:08
  • I wasn't asking for my user shell, but rather the script shell that executes daemons. The first answer made it. May 20, 2013 at 12:51
  • 1
    Actualy my answer and the other one are exactly the same (the clever " |awk ... " bit does extract the same string I mention). I agree that user shell and 'daemons' shell are very different things. It's the shebang line of every script in /etc/init.d that rules. In Centos it is usually #!/bin/sh or #!/bin/bash (and /bin/sh is usually a link to /bin/bash). I strongly advise against to mess up with this shebangs nor with this link or very bad things will follow.
    – DavAlPi
    May 20, 2013 at 13:30
  • 1
    the point here is that Centos startup scripts are written specifically for Bash (#!/bin/bash) or for a particular mode of bash that mimic "historical versions of sh" (#!/bin/sh). If you try to change the shell (changing the link at /bin/sh) you broke things. In recent Debian/Ubunt the scripts (and the shell) use dash and ever here is unwise to force another shell for the same reasons.
    – DavAlPi
    May 20, 2013 at 13:41
  • If the centos scripts are made for bash that mimics sh, and dash also does this, in theory there would be no breaks. But I don't know and if I don't try I will truly never know. May 20, 2013 at 16:42

the best way to change it is to use usermod in Centos

usermod -s /bin/bash username

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.