Korn Shell Programming Resources

KornShell, or just ksh, is a Unix shell that was developed by David Korn at Bell Labs in the early 1980s. Ksh is based on Bourne shell (sh), provides complete backward compatibility with sh, includes many C shell (csh) features, adds additional features that are unique to ksh, and runs faster than either sh or csh.

Ksh is the default shell used with IBM's AIX operating system, the once popular but now-defunct OpenSolaris operating system. While ksh is primarily an interactive command language, it can also be used as a high-level programming language and is useful for writing automated scripts.

Bourne, C, and Korn Shells

Bourne shell was created by Stephen Bourne at Bell labs in 1979 and first distributed with UNIX Version 7. Sh is typically located at /bin/sh in a Unix file system directory. As a result sh is commonly used as a shorthand way of referring to Bourne shell.

Several other Unix shells were developed to maintain backward compatibility with sh while adding new features.

  • Bourne-Again shell, or bash, is the most popular command-line interface and the default shell used in most Linux systems and in Apple OS X.
  • Debian Almquist shell, or dash, is a shell language commonly used on Debian and Ubuntu systems.
  • Several other shells can also be traced back to sh.

While Stephen Bourne was creating sh at Bell Labs, Bill Joy was busy creating C shell (csh) while a student at UC Berkely. Csh was released as part of the second version of BSD in 1979. It is very different from the Bourne shell. It was designed to be much more similar to the C programming language than other Unix shells available at the time.

In 1983, ksh was released as a proprietary Unix shell for Bell Labs (and later AT&T) users. It was backward compatible with sh and included many features borrowed from csh at the request of Bell Labs users. Ksh remained a proprietary AT&T shell until the year 2000 when it was released as open source software. Since ksh was proprietary software from 1983 until 2000, several open source shells based on ksh sprang up with the most popular being Public domain Korn shell (pdksh) and MirBSD Korn shell (mksh).

What Can You Do With Ksh?

Ksh scripting can be used in two different ways:

  • Ksh can be used interactively to execute commands typed into a command line prompt.
  • Ksh can be used programmatically to create scripts to automate a wide variety of operating system and system adiministration tasks.

Shell languages are primarily used to write code that launches other programs. However, entire scripts can also be written in shell languages such as ksh and used to automate any repetitive adminstrative task. Some of the tasks most commonly tackled with ksh or other shell languages include:

  • Writing scripts that will execute when a computer system boots up;
  • Writing scripts that automate computer maintenance tasks;
  • Downloading and installing application packages.

Online Ksh Tutorials and Videos

The best online resource for programmers who are just getting started with ksh is the Korn shell scripting beginner's guide from IBM developerWorks. This short tutorial, which is also available in pdf, quickly introduces Unix shells, variables, loops, ksh syntax, and much more. In the 15 minutes required to review this resource, you will learn the basics that will help you understand other more-challenging tutorials.

James Maher, an experienced Unix programmer and systems admin, released a series of 80 free KornShell tutorial videos on YouTube. These videos assume that you have some familiarity with the command line but no prior experience with ksh. If you already have ksh up and running on your system, these videos cover a lot of ground including variables, debugging, arrays, lists, if statements, pattern matching, loops, functions, and a lot more. You'll want to supplement these videos with written training which provides greater depth, but these videos are an excellent way to reinforce the topics presented in written format in other resources.

Philip Brown, a Solaris systems administrator and experienced programmer at the University of Southern California, has written a free Korn Shell (ksh) Programming tutorial. The tutorial covers topics such as variables, functions, redirection, and a lot more.

If you're up for something a little more academic, Unix shell scripting with ksh/bash is a detailed, electronic, course handout. It was created by Richard Brittain, a Research Systems Engineer in the Information Technology Services department at Dartmouth College.

Ksh Reference

Even experienced programmers refer to reference documents on a regular basis. Here are two reference resources you can use to locate detailed instructions about specific ksh features when you need them.

  • The KornShell website includes information about ksh, links to the latest version of the software, documentation, and more.
  • IBM maintains a complete, well-organized ksh reference library that covers the entire ksh language. This document isn't a tutorial by any means, but if you need to look up a specific feature of the language, this is an excellent resource.


Many programmers learn to use ksh by studying texts written on the topic. If you do follow a text, it's important that you not try to just jump in at a point that looks interesting. Skipping into the middle of one of these texts will lead to confusion since the text in each chapter builds on the content presented in previous chapters. Read the information presented in these texts in the order presented to get the most out of them.

  • Classic Shell Scripting by Robbins and Beebe is a solid introduction to shell scripting. If ksh is your first shell programming language you would be wise to solidify your understanding of shell scripting in general before moving on to ksh-specific texts.
  • KornShell Programming Tutorial by Barry Rosenberg is the most highly recommended KornShell programming text available.
  • Learning the Korn Shell by Robbins and Rosenblatt is part of the popular O'Reilly Media series of computer programming books. While not as popular as KornShell Programming Tutorial, this text is nonetheless very well-respected and acknowledged within the Unix programming world.
  • The New KornShell Command And Programming Language co-written by David Korn himself is not for beginners. However, experienced programmers will appreciate the technical depth of this text. Plus, how can you go wrong selecting a programming langauge text written by the creator of the language?


Korn (not that KoRN) Shell is a Unix shell programming language you can use interactively to execute commands from the command line or programmatically to create scripts that can automate many computer maintenance and system administration tasks. In addition to ksh, another shell you should know about is bash.