Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

By typing echo $0, I know I'm using tcsh in my Ubuntu 13.04 terminal. However no matter using chsh -s /bin/bash or just typing bash still can't make bash as my present shell. The interesting thing is that, if I type sh, then my shell will be sh. Finally I found a more interesting thing: each time after I typing bash, I type ps to see the change, I found I get two more lines: one is new bash PID, another is new tcsh PID, which means each time after I tried to use bash shell, system automatically change my shell back to tcsh immediately. How can I solve this? Please help me!Thanks!

share|improve this question
    
maybe your ~/.bashrc file contains a csh (or tcsh) command that's causing a new tcsh subshell to be spawned inside each bash shell? have you tried grep csh ~/.bashrc? –  steeldriver Oct 11 '13 at 8:11

2 Answers 2

up vote 2 down vote accepted

By using echo $0, you will get the name of the running process, the name of the file as was invoked on the command line, the name of the command currently being executed (see Special shell variables). The right command which will return your current shell where you are in is:

echo $SHELL

Therein lies probably your confusion. And yes, the right command to change your default shell is:

chsh

Better to use it without any arguments to see exactly what happens.

share|improve this answer
    
actually why i am aware of using tcsh not bash is because when I want to add a path, I have to type" sentev PATH=$PATH:." instead of "export .....".I tried to use "chsh" interactively, but doesn't work. but I found the function of chsh is to change the default shell of login shell, but i am using non login shell. is this the reason it doesn't work? and I find, if I type" sudo -i" to be root user,then the shell become bash automatically. However in nonlogin shell, I can never change to bash. –  user2869734 Oct 11 '13 at 14:06
    
@user2869734 What is the output of cat /etc/passwd | grep $USER | cut -d":" -f7 command? –  Radu Rădeanu Oct 11 '13 at 14:11
    
I'm so sorry of being so late. I get "/bin/bash" after I typed the command line you gave me. But now it seems i know the reason. Probably my professor installed tcsh on my laptop which is in /usr/bin, and in my PATH, i found /usr/bin this directory is in the front of /bin where -bash is. so after i deleted the tcsh, bash finally come back.Thanks! –  user2869734 Oct 14 '13 at 20:24

First type cat /etc/shells to see a list of available shells then use chsh to interact & change the shell. If you want to use it from a script use chsh --shell SHELLNAME.
I also suggest to read /etc/login.defs to see what you can customize, it's interesting & useful.
Have a nice day.

share|improve this answer

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.