Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: 1.3 History of UNIX ShellsChapter 1
Korn Shell Basics
Next: 1.5 Interactive Shell Use
 

1.4 Getting the Korn Shell

You may or may not be using the Korn shell right now. Your system administrator probably set your account up with whatever shell he or she uses as the "standard" on the system. You may not even have been aware that there is more than one shell available.

Yet it's easy for you to determine which shell you are using. Log in to your system and type echo $SHELL at the prompt. You will see a response containing sh, csh, or ksh; these denote the Bourne, C, and Korn shells respectively. (There's also a remote chance that you're using a third-party shell such as bash or tcsh.)

If you aren't using the Korn shell and you want to, then first you need to find out if it exists on your system. Most major UNIX versions released since roughly 1989 come with it-especially those derived from AT&T's System V Release 4. Just type ksh. If you get a new dollar-sign prompt ($), then all is well; type exit or press CTRL-D to go back to your normal shell.

But if you get a "not found" message, your system may not have it. Ask your system administrator or another knowledgeable user; there's a chance that you might have some version of the Korn shell installed on the system in a place (directory) that is not normally accessible to you. But if not, read Appendix A to find out how you can obtain a version of the Korn shell.

Once you know you have the Korn shell on your system, you can invoke it from whatever other shell you use by typing ksh as above. However, it's much better to install it as your login shell, i.e., the shell that you get automatically whenever you log in. You may be able to do the installation by yourself. Here are instructions that are designed to work on the widest variety of UNIX systems. If something doesn't work (e.g., you type in a command and get a "not found" error message or a blank line as the response), you'll have to abort the process and see your system administrator.

You need to find out where the Korn shell is on your system, i.e., in which directory it's installed. You might be able to find the location by typing whereis ksh (especially if you are using the C shell); if that doesn't work, try whence ksh, which ksh, or this complex command:

grep ksh /etc/passwd | awk -F: '{print $7}' | sort -u

You should see a response that looks like /bin/ksh or /usr/local/bin/ksh.

To install as your login shell, type chsh ksh-name, where ksh-name is the response you got to your whereis command (or whatever worked). You'll either get an error message saying that the shell is invalid, or you'll be prompted for your password. Type in your password, then log out and log back in again to start using the Korn shell. If you got an error message, you'll just have to see your system administrator. (For system security reasons, only certain shells are allowed to be installed as login shells.)


Previous: 1.3 History of UNIX ShellsLearning the Korn ShellNext: 1.5 Interactive Shell Use
1.3 History of UNIX ShellsBook Index1.5 Interactive Shell Use

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System