How do I change my default shell to bash if I don't have access to chsh nor /etc/passwd?
Sophia Terry
I'm working on a university remote Linux account, and the default shell is sadly csh without tab completion. How can I change my account's default shell to bash? chsh is not available.
4 Answers
You should probably try asking your sysadmins if they can change your default shell for you. If they can't or won't (as was the case when I was in college), the workaround I used was to add
# Exec bash if using an interactive shell.
if ($?prompt) then setenv SHELL /path/to/bash exec $SHELL
endifto .cshrc. (Make sure to replace /path/to/bash with a real path, of course. This could even be a version of bash that resides under your home directory, if the system-provided version is too out-of-date for your taste.) For efficiency, it's best to do this as early in the .cshrc as feasible, so that you avoid additional .cshrc processing that will become moot once bash replaces the csh process.
You could simply connect with
ssh -t yourhost bashto execute the Bash shell automatically when you log in.
From the comments below you can see the alternative
ssh -t yourhost exec bashexec will run a new process and exit the old one, so the csh process will exit directly.
If append -l at the end of the command as an argument to Bash, it will be treated as a login shell, but perhaps that is not needed.
The best solution I found was one over on stackexchange. Here is the link stackexchange and here is the solution:
create a .profile file in your home dir and paste in the following, or add to the end of your .profile if you already have one.
case $- in *i*) # Interactive session. Try switching to bash. if [ -z "$BASH" ]; then # do nothing if running under bash already bash=$(command -v bash) if [ -x "$bash" ]; then export SHELL="$bash" exec "$bash" fi fi
esac i searched a lot when your using LADP authentication via PAM , i think the best solution is to put SHELL=/bin/bash exec /bin/bash in .profile file in your user home directory