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
Output:

/usr/local/bin/bash

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

Password

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
From
vivek:x:1000:1000:vivek,,,:/home/vivek:/bin/sh
To
vivek:x:1000:1000:vivek,,,:/home/vivek:/usr/local/bin/bash

Save and close the file.

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.