There are still some computing systems where the user is expected to
use a C shell (like csh or tcsh) instead of
standard bash. Although unix (usually Linux) systems
provide users with a good deal of environment configuration options
(like installing programs in home directory), it's not necessarily
easy to override this system-wide decision. The problem is that the
user's shell is configured in the system password file
(/etc/passwd). On some systems the user can choose the
setting there using chsh tool, but even then the list of
choices is determined by the administration.
This document describes my setup in a system constrained like this. Every shell needs different kind of setup, but the setup might be partly applicable if your situation constitutes of shells other than a C shell and bash. The setup doesn't need administrative (ie root) priviledges on the system, and all environment configuration by the administarion is still loaded in the shell. The setup works at least for ssh logins and ssh remote command execution.
$ grep username /etc/passwd
The last field tells you which shell you are set up to use. This is started by the login procedure.
$ chsh -l
This will give you the list of shells you can choose using chsh. If
this lists the shell you want to use, you can just proceed with
$ chsh -s your choice
This is the default way to change your shell, but it might be that the shell you want is not on the list. Note, that even if you could change your shell using chsh, it might not be the best thing to do. That's because if the shell you choose is not supported (officially or unofficially) by the administration, it probably isn't configured right.
$ locate */shell
This tells you the full path to the shell you'd like to use
instead. Replace /bin/bash in my examples with it. If
locate didn't find the shell, you should go and download the shell
source code archive, compile it and install it under your home directory.
When a C shell starts, it will run it's initialization scripts, some
of them located in the user's home directory. We'll simply go and add
a final setup step to the end of the startup - to start bash. Just add
these lines into file .cshrc in your home directory
(create file if there is not one yet):
# .cshrc: executed by C shells on startup
# If this is login or some command is to be executed
# then change to a sane shell
if ($?loginsh || $?command) then
setenv SHELL /bin/bash
if($?loginsh) exec /bin/bash --login
exec /bin/bash -c "$command"
endif
Notice that if you have a file named .tcshrc in your home directory, tcsh will read that file instead of .cshrc. In that case, you can remove .tcshrc or append these lines also to it.
This way, the C shell will still be launched and the initialization scripts of the administration will be run. But when the init is completed, the C shell process is replaced by bash, either giving a prompt if you're logging in or running the command if it was stated (this happens if you run a remote command using ssh).
If you had to install or set up bash yourself, you probably don't have any
configuration files. .bash_profile is sourced for login shells and
.bashrc for others. The normal setup includes in
.bash_profile lines to source .bashrc also for login
shells, to set up the environment:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
If you don't know of anything better or don't care, you can use my scripts as a basis: