What the Shell? Getting Started with Unix
- Discovering What Shell You're Using
- Understanding Shells and Options
- Changing Your Shell with chsh
- Changing Your Shell Temporarily
- Using Completion in the bash Shell
- Viewing Session History in the bash Shell
- Using Completion in the zsh Shell
- Viewing Session History in the zsh Shell
- Using Completion in the ksh Shell
- Viewing Session History in the ksh Shell
- Viewing Session History in the csh Shell
- Changing Your Identity with su
- Fixing Terminal Settings with stty
- Exiting the Shell
Chapter Contents
- Discovering which shell you're using
- Understanding shells and options
- Changing your shell
- Changing your shell temporarily
- Using completion in the bash shell
- Viewing session history in the bash shell
- Using completion in the zsh shell
- Viewing session history in the zsh shell
- Using completion in the ksh shell
- Viewing session history in the ksh shell
- Viewing session history in the csh shell
- Changing your identity
- Fixing terminal settings
- Exiting the shell
When you access a Unix system, the first thing you see is the prompt, called the shell prompt, which is where you interact with Unix. The shell determines how easily you can enter and reenter commands and how you can control your environment. What's cool about Unix is that you're not stuck with one shell—that is, on most systems you can choose to use shells that have different features and capabilities.
In this chapter, we'll look at your shell, show you how to change your shell, and get you started using a few of the more common shells.
Discovering What Shell You're Using
When you first log in to your Unix account, you'll be using the default shell on your system. The default shell, its features, and its options depend completely on what your system administrator specifies. Code Listings 3.1 and 3.2 show examples of how default shell prompts differ on two different systems.
Code Listing 3.1. This ISP account uses the /bin/csh shell by default.
xmission> echo $SHELL /bin/csh xmission> finger ejray Login name: ejray In real life: "RayComm Directory: /home/users/e/ejray Shell: → /bin/csh On since Jul 23 06:58:48 on pts/16 from → calvin.raycomm.com 1 minute 28 seconds Idle Time No unread mail No Plan. xmission>
To discover what shell you're using:
-
echo $SHELL
At your shell prompt, type echo $SHELL (capitalization counts!). This command tells Unix to display (echo) information about shell settings. This information, by the way, is contained in one of the environment variables, so the technical phrasing (which you might hear in Unix circles) is to "echo your shell environment variable."
The system's response will be the full path to your shell—something like /bin/csh, /bin/bash, or /bin/ksh.
Code Listing 3.2. On hobbes, a Linux system, the default shell is /bin/bash.
[ejr@hobbes ejr]$ echo $SHELL /bin/bash [ejr@hobbes ejr]$ finger ejr Login: ejr Name: Eric J. Ray Directory: /home/ejr Shell: /bin/bash On since Wed Jul 22 07:42 (MDT) on tty1 → 3 hours 15 minutes idle On since Thu Jul 23 08:17 (MDT) on ttyp0 → from calvin No mail. Project: Working on UNIX VQS. Plan: This is my plan-work all day, sleep all → night. [ejr@hobbes ejr]$