37

I have csh as my default shell, as shown by echo $SHELL. I want to switch to bash as my default shell. I tried the following approaches to no avail:

  1. With chsh I get:

    chsh: can only change local entries; use ypchsh instead.
    
  2. With ypchsh I get:

    ypchsh: yppasswdd not running on NIS master host ("dcsun2").
    

I only have .chsrc in my home directory and I cannot find any .profile files in /etc. How can I change my default shell to bash?

Kusalananda
  • 333,661
Sumod
  • 597
  • 2
  • 6
  • 9

2 Answers2

48
  1. Make sure you've got bash installed.

  2. Learn the location of bash:

    which bash
    

    or

    whereis bash
    

    Below, I'll assume the location is /bin/bash.

    a) If you have administrative rights, just run as root:

    usermod -s /bin/bash YOUR_USERNAME
    

    (replacing YOUR_USERNAME with your user name).

    b) If you don't have adm. rights, you can still just run bash --login at login, by putting the below line at the end of your .cshrc or .profile (in your home directory) :

    setenv SHELL /bin/bash
    exec /bin/bash --login
    
  • 2b. Check if bash is enumerated in /etc/shells with correct path. – manatwork Sep 13 '11 at 16:37
  • @manatwork That would be relevant for 2a, not 2b. And only useful in a strange/broken system setup for determining why the solution did not work. – rozcietrzewiacz Sep 13 '11 at 16:46
  • Yes, actually my intention was to write something like "2a.b". – manatwork Sep 13 '11 at 17:02
  • 1
  • SHELL=/bin/bash gives a command not found error. 2. Your solution gives me a bash shell as the prompt. But it does not change my login shell. Thanks for the help though.
  • – Sumod Sep 14 '11 at 06:37
  • 1
    Here is what I did to resolve this. 1. exec /bin/bash --login in the .cshrc file 2. set SHELL=/bin/bash and then export SHELL in the /etc/profile file. Thanks. – Sumod Sep 14 '11 at 08:41
  • 2
    Ah, sorry - I meant the first line to be export SHELL=/bin/bash. Actually there's a better way than that - see update. – rozcietrzewiacz Sep 14 '11 at 14:04
  • You don't have to do the which/whereis separately. For example, SHELL=`which bash` `which bash` YOUR_USERNAME – Kevin Nov 21 '15 at 16:43
  • exec /bin/bash without --login works for me – kchoi Aug 26 '16 at 20:16
  • exec /bin/bash --login does not seem to be reading .bashrc – Marcus Junius Brutus Oct 18 '16 at 16:38
  • @MarcusJuniusBrutus Because it is not supposed to do so. This seems to be a very common misconception - some distributions even ship default .bash_login, .profile or similar files which remedy this. But that is quite far from the original subject. You may ask a separate question. – rozcietrzewiacz Oct 18 '16 at 17:46
  • This seems to break non-interactive uses, like scp. You need if ($?prompt) then; exec /bin/bash --login; endif – joeln Mar 14 '18 at 00:33
  • WARNING: After adding exec /bin/bash, scp stopped working for me. – dips Oct 14 '18 at 14:38