Definition

shell program

What is a shell program?

A shell program is software that provides users with an interface for accessing services in the kernel. The kernel manages the operating system's (OS) core services. It's a highly protected and controlled space that limits access to the system's resources. A shell provides an intermediary connection point between the user and the kernel. It runs in the system's user space and executes the commands issued by the user, whether through a keyboard, mouse, trackpad or other device.

On some platforms, the shell is called a command interpreter because it interprets the commands the user issues. The shell then translates those commands into system calls in the kernel. Each system call sends a request to the kernel to perform a specific task. For example, the shell might request the kernel to delete a file, create a directory, change an OS configuration, connect to a network, run a shell script or carry out a variety of other operations.

How does a shell program work?

A shell program is either a command-line interface (CLI) or a graphical user interface (GUI). Some sources consider only CLI programs to be actual shells, or they conflate command terminals with the shells themselves. However, a shell can be either a CLI or GUI, and it isn't a terminal. A terminal merely provides a command prompt for working with a shell. For example, the default terminal in macOS is named Terminal, and the default terminal in Windows is called Command Prompt. Neither is considered a shell.

Most OSes provide a default CLI shell, although they typically support other shells as well. When working in a terminal, a user can issue commands directly to a shell by entering the commands at the command prompt. For example, Figure 1 shows a Terminal window in macOS. In this case, Z shell (zsh) is the active shell, which is now the default shell in macOS. Before that, bash (Bourne Again Shell) was the default shell.

Terminal commands
Figure 1 shows four commands, each instructing the kernel to carry out a task.

Figure 1 shows four commands, each on a separate command line, along with the results returned by those commands, where applicable. The Terminal app opens at the user's home directory, which is represented by the tilde (~) in the command prompt. In this case, the command prompt is customized to show the current directory, followed by a colon and then by a percentage sign (%). The four commands in the figure instruct the kernel to carry out the following tasks:

  • cd documents/testdata changes the working directory from the default directory or home directory to the TestData child directory within the Documents directory. If the current user doesn't have the permissions necessary to view that directory's contents, the kernel denies access. After the user runs the command, the command prompt displays the name of the child directory, which is now the current directory.
  • ls -l lists all the nonhidden contents in the current directory. The command includes the -l option, which instructs the kernel to return the information in the long format. If this option hadn't been included, the command would have returned only the file names. Like many zsh commands, the ls command supports numerous options, including the use of wildcards, to help better control the operation.
  • cd ~ changes the working directory back to the user's home directory.
  • cal displays a calendar of the current month, with the current date highlighted.

A shell such as zsh supports a wide range of commands, substantially more than those shown here. Many of those commands support multiple options for better controlling how the kernel carries out a task. Some commands also work the same across different shells, making it easier to move from one shell to the next.

Users have a wide range of CLI shells from which to choose, depending on the OS they use. In addition to zsh and bash, other common CLI shells include Bourne shell, C shell, Korn shell and friendly interactive shell.

Some CLI shells are available on multiple platforms. For example, bash is available for Unix, Linux and macOS platforms. It can also run on Windows when using Microsoft Windows Subsystem for Linux. Because bash is supported on multiple platforms, bash scripts are often portable across these platforms, especially when it comes to Unix-like systems.

There are also many GUI shell programs available, although they're not as flexible as CLI shells. Graphical shells are created for specific OSes and can take different forms. For example, Figure 2 shows a screenshot of the Ubuntu desktop with several applications open. Ubuntu uses GNOME Shell to provide a user interface for the underlying GNOME desktop environment.

Ubuntu desktop
Figure 2 shows the Ubuntu desktop with several applications open.

But GNOME Shell isn't the only Linux desktop shell available. KDE Plasma is also a common Linux shell, as is Unity, which is based on the GNOME desktop environment, like GNOME Shell. There are also desktop shells for other environments, such as the Windows shell, which provides a desktop GUI for the Windows OS. However, a graphical shell isn't limited to an entire desktop. For example, Finder in macOS is considered a graphical shell because it provides users with access to kernel services.

What's the difference between scripting and programming languages? Learn what defines programming and scripting languages and what makes them stand apart.

This was last updated in December 2023

Continue Reading About shell program

Dig Deeper on Data center ops, monitoring and management

SearchWindowsServer
Cloud Computing
Storage
Sustainability
and ESG
Close