Setting bash as default shell

Q. I am using FreeBSD and I would like to setup bash as default shell?

A. CSH is default shell under FreeBSD. First, make sure bash is installed. Type bash to see if you can execute bash:
$ bash
If you get command not found error. Use pkg_add command to install bash
# pkg_add -r -v bash

Now to setup bash as shell type chsh command.
chsh -s /path/to/shell {user-name}

chsh changes the user login shell. This determines the name of the user’s initial login command. A normal user may only change the login shell for her own account, the super user may change the login shell for any account. To setup bash default shell for user vivek, type command:

$ which bash


Now change shell:
$ chsh -s /usr/local/bin/bash vivek


Provide your login password. Verify that shell is changed:
$ grep ^vivek /etc/passwd

You can also edit /etc/passwd file and change shell (you need to login as root user):
# vi /etc/passwd
Last filed is shell

Save and close the file.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • Jose Sep 22, 2007 @ 17:37

    Don’t forget to create a .bash_profile page or do what I do (from your home dir):

    ln -s .bashrc .bash_profile

  • naila Oct 1, 2007 @ 5:55

    i downloaded this bashish.tar file and ran configure,make,make install,but in the end it wanted me to instal an interactive utility for chnaging the themes..i was annoyed as i was working in the i deleted it..but i had already applied the exec bash comand and now my prompt is -bash-3.00#… i dont knw how to change it back to naila@root# plz help me

  • Md. Hasan Mahmud Riyad Aug 31, 2008 @ 4:00

    Hello Vivek,
    Really a great Job done by you and your coworkers, All tips and tricks are helpfull. and also good understanding for new users. Thank you again for this knid of open source work

    Riyad, Dhaka, Bangladesh

  • GregMo Sep 9, 2008 @ 1:49

    If I missed something here then please forgive me. The question was how do you setup bash to be the default shell. Did I miss that part, or does the response only tell how to change existing accounts to bash?

    To change the default shell one must edit /etc/adduser.conf. Now, if as in my case, this file isn’t present, then you need to run `adduser -C’ to create the file with the defaults you want.


  • Drey Jan 7, 2011 @ 8:31

    Followed, but still see csh welcome in new tab of Terminal in xfce on FreeBSD.
    /etc/passwd shows bash. What I’ve missed?

  • Querry Jun 7, 2011 @ 13:28

    @ Drey: You need to reboot, after that the Terminal starts with bash.
    Also you can just do a logout an then login again, result will be the same!

  • Drey Jun 7, 2011 @ 14:47

    Thanks, Querry.
    Another question:

    I’m connecting via ssh to my freebsd box:
    getting uncoloured , but bash prompt:
    [drey@kiwi ~]$ ps aux |grep `echo $$`
    drey 73463 0.0 0.8 4560 1984 1 Ss 11:54PM 0:00.03 -bash (bash)
    # then I’m executing bash once again:
    [drey@kiwi ~]$ bash
    # and voila, ~/.bashrc executes fine and I see coloured and customized prompt:
    [drey@kiwi 23:55 ~] ps aux |grep `echo $$`
    drey 73481 0.0 0.8 4560 1992 1 S 11:55PM 0:00.02 bash
    [drey@kiwi 23:55 ~]exit
    [drey@kiwi ~]$ ps aux |grep `echo $$`
    drey 73463 0.0 0.8 4560 1964 1 Ss 11:54PM 0:00.03 -bash (bash)

    Why at first connect ~/.bashrc doesn’t execute?

  • folivora Jun 25, 2011 @ 11:23

    @ Drey.

    You also need .bash_profile. So just create symbolic link, ln -s .bashrc .bash_profile.

    • Drey Mar 12, 2012 @ 9:05

      Thanks, worked!

  • khalil Mar 11, 2012 @ 23:25

    Wish you can help me to solve this problem ! i installed cuda toolkit & pyrit. As the installation required modifying the bashrc file by appending the following command:”PATH=$PATH:/opt/cuda/bin
    export PATH
    export LD_LIBRARY_PATH” to it, i lost colour in my shell, and the alias & the rest of directories & subdirectories are no longer coloured in a beautiful way :-( but they are all in white !!! how can i restore the same colours please?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum