Changing Your Shell


The default shell for the root user in FreeBSD is csh (actually tcsh). If you're not running as root, however, you might have a different shell assigned. To see what shell you are currently running, type the following command, where foo is your login name and # is the command prompt:

# grep foo /etc/passwd


Don't worry if you don't know what this command line means. You'll understand it and far more before you are done with this chapter. The command returns a line that looks something like the following:

foo:*:1001:1001::Foo Bar:/home/foo:/bin/csh


The line on your screen will probably be different from this one. For now, all you need to worry about is the last field (the one that reads /bin/csh in the example). This is your default shellin this case, the csh shell. Your result will probably have one of the following values:

  • /bin/sh The POSIX Bourne shell.

  • /bin/csh The C shell, which is actually a hard link, or alias, to the tcsh shell. If your shell is /bin/csh, you are actually running tcsh.

  • /bin/tcsh The tcsh shell.

  • /usr/local/bin/ksh The Korn shell.

  • /usr/local/bin/bash The bash shell.

Suppose you want to switch to another shell, for example the Bourne Again Shell, bash. To install bash, choose it from the packages on the included DVD (in the shells category) or build it from the ports, as described in Chapter 16. After it has been installed, log out and back in to register that bash is now a command that you can run.

To run the bash shell, simply type bash at the command prompt to begin a new session using the bash shell. This instance of bash is actually running within your original csh session, and you'll return to csh when you quit bash. In Chapter 9, "Customizing the Shell," you'll see how to permanently change your shell, so that bash is what is executed as soon as you log in, instead of csh.

Caution

Unlike DOS, Windows, and VMS, UNIX and FreeBSD are case-sensitive. For example, the names Grep, grep, and greP are completely unrelated to each other as far as FreeBSD is concerned. This is a common source of errors for newcomers. If you are getting No such file or directory errors when you type commands in this chapter, make sure you are capitalizing your commands exactly as they're written.


You'll notice that the command prompt changes when you run the new shell. This is because different shells have different default styles for their prompts. If you're running as root (under csh), and your computer is called simba, you'll see the prompt change like this when you run bash:

simba# bash root@simba#


The # prompt character traditionally denotes that you're running as root (to remind you of your potentially dangerous capabilities). If you're running as a regular user, csh uses the % character, and bash uses $, so these two lines would look like this:

%bash btman@simba$


Notice that the default prompt under csh shows your computer's hostname and nothing else if you're root, and no information at all if you're not root. The default bash prompt communicates both your username and the computer's hostname, as well as indicating whether you're root or not with the final character. All this behavior can be changed, and you can read how in Chapter 9.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net