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.

  • 1
    What system does the university use to store accounts? ldapmodify might work. – grawity Aug 30 '12 at 15:12
  • Or, if they are using NIS, ypchsh should be the proper command. – m000 Aug 30 '12 at 17:17
  • If you just want tab completion you could add these to your ~/.cshrc set filec and set autolist. – Hennes Nov 22 '13 at 18:36

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

to .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.

  • This did not work for me at my university. I will probably have to talk to the sysadmin. – 2rs2ts Mar 27 '13 at 14:13

You could simply connect with

ssh -t yourhost bash

to execute the Bash shell automatically when you log in.

From the comments below you can see the alternative

ssh -t yourhost exec bash

exec 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.

  • 1
    ssh -t yourhost exec -a bash -l bash to replace the original shell completely, rather than running as a process inside the initial shell. – chepner Aug 30 '12 at 14:43
  • @chepner: Interesting, I'm using a simple ssh -t host bash solution myself in a similar situation, but your way is better. I haven't thought of exec at all, thanks! I'll update the post with your suggestion. – Daniel Andersson Aug 30 '12 at 16:20
  • I got a little fancy, though, using arguments for the bash built-in command exec. – chepner Aug 30 '12 at 16:25
  • @chepner: Ah yes, I tried it now on a host with zsh as default shell and it fails on both -a and -l. I'll modify the example in my answer. – Daniel Andersson Aug 30 '12 at 16:33

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
    # 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"

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.