Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

3 Answers

up vote 5 down vote accepted

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
endif

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.

share|improve this answer
    
Thank you so much! –  mcandre Aug 31 '12 at 19:39
    
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
add comment

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
share|improve this answer
add comment

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.

share|improve this answer
    
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
add comment

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.