Hi all,I installed cent OS in my machine. Now when i open the terminal and start writing some commands, then by default with which shell i am working with?
Will i be able to change the shell and then run a few commands? if possible then how to change the shell?
1) Don't edit /etc/passwd directly unless you really know what you are doing. If you do have to do it in an emergency, use "vipw" and definitely not "vi".
To change a default shell for a user just use the "usermod" command.
2) If you log in with one shell and want to change to another shell which is installed on your computer, just type the path to that shell:
e.g.
/usr/bin/ksh
(i.e. Don't type a # character).
If the shell does not change it can be because some Linux machines link all likely shell names to "bash".
The reason is that the variable "SHELL" is set only in the first shell which is started, not in any shells strated subsequently. I ran across this phenomenon when i tried to create a shell-independent script and wanted the script to be aware under which shell it is being run.
If your standard shell in /etc/passwd is "ksh" then "echo $SHELL" will say "ksh", even if you have started a bash instance in the meantime. If your standard shell is "bash" it will read "bash" even if you started a ksh.
What you can do is expand the variable "${.sh.version}", which is specific for the ksh and only set if the current shell is running. On the other hand you can expand the variable "$BASH_VERSION" only if a bash is running:
# echo $SHELL
/bin/ksh
# echo ${.sh.version}
Version JM 93t+ 2010-06-21
# bash
# echo $SHELL
/bin/ksh
# echo ${.sh.version}
bash: ${.sh.version}: bad substitution
# echo $BASH_VERSION
4.1.2(1)-release
# exit
# echo ${.sh.version}
Version JM 93t+ 2010-06-21
# echo $BASH_VERSION