You are here: DesktopBSD Wiki Portal » doc » How to change the shell

Translations of this page?:

How to change the shell

Do not change the shell for root!

The default shell in DesktopBSD is the the BASH shell, but some people prefer other shells such as csh, tcsh, or sh.

This is a fairly easy change, but it does require some command line work. One of the great things about GUIs is the ability to cut and paste the commands directly into the console application if you're already running DesktopBSD.

First thing to do is open the Konsole terminal application, it should be under the System subsection in the KDE application menu. Once Konsole is open, you'll need to su up to root.

su root

At this point you'll be prompted for a password. Type the root password and press enter. If the prompt changes to “hostname#”, then the command was successful; otherwise, “su: sorry” will be displayed.

Once you have successfully become root, you can start modifying your user account. The command that is going to be used is the pw utility which is edits system user and group information.

First take a look at the user you're going to change the shell for.

pw user show username

It will return some text that looks like the following:

username:*:1001:1001::0:0:Full UserName:/home/username:/usr/local/bin/bash

The very last part, /usr/local/bin/bash, is the current shell of the user. In this example it's still the bash shell.

To change that enter the following code.

pw user mod username -s /bin/tcsh

The above example is for the tcsh shell, but if you want another shell just change /bin/tcsh to the absolute path of your preferred shell. DesktopBSD comes with sh (/bin/sh), csh (/bin/csh), tcsh (/bin/tcsh), and bash (/usr/local/bin/bash) installed by default, and there are more shells that can be install via ports if none of those are to your liking.

Now check to make sure the change was successful.

pw user show username

It should now display text that is close to the following if it was successful. You don't have to check normally, only for the purposes of this wiki entry.

username:*:1001:1001::0:0:Full UserName:/home/username:/bin/tcsh

Drop back down into regular user mode.

exit

Exit out of Konsole, and if you modified your user logout then back in for the modification to take affect.

Addendum

Furthermore you can change the shell with the chsh command. Before running the command, people new to FreeBSD should make sure the default editor is set to Easy Editor (ee) as most beginners have some difficulty using vi/vim.

To check and see which editor is set as default, issue the following command:

echo $EDITOR

The next line will display the shell's default editor. If anything other then ee is output, the the variable needs to be changed with the appropriate command.

csh/tcsh:

setenv EDITOR ee

bash/sh:

export EDITOR=ee

This changes the default editor from vi to ee.

Once the default editor has been set, or it has been determined that ee is the default editor, issue the command:

chsh username

ee will launch with the information for the indicated user loaded, as in the example below.

  #Changing user information for username
  Shell: /usr/local/bin/bash
  Full Name: User &
  Office Location:
  Office Phone:
  Home Phone:
  Other information:

Change the “Shell:” line to the location of the desired shell (e.g. Shell: /bin/tcsh). As you can see it is rather easy.