Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

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)"
share|improve this answer
Wow, thank you, in my machine sh is a link to bash.lrwxrwxrwx. 1 root root 4 mar 9 22:42 /bin/sh -> bash – NotFromBrooklyn May 20 '13 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

share|improve this answer
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 '15 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.

share|improve this answer
If you want to change your shell, use chsh. – schaiba May 20 '13 at 10:08
I wasn't asking for my user shell, but rather the script shell that executes daemons. The first answer made it. – NotFromBrooklyn May 20 '13 at 12:51
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 '13 at 13:30
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 '13 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. – NotFromBrooklyn May 20 '13 at 16:42

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

usermod -s /bin/bash username
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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