Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

3 Answers 3

up vote 2 down vote accepted

You can determine your default shell by flowing 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
add comment

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
add comment

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
john1:x:501:1000:john1,,,:/home/john1:/bin/bash

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
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 '13 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 '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
show 1 more comment

Your Answer

 
discard

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.