what is a command shell in linux

Many posts on this site deals exclusively with how to get things done in Linux using just a command shell. We use the terms shell, command shell, command prompt, command line, console and terminal interchangeably most of the times. In most cases, it does not matter and it all means the same but there is some subtle differences between shell and terminal.

Command Shell

A command shell or shell is a software program that accepts commands from the keyboard and then executes either by itself or by passing it on to the underlying operating system. The shell is known by various different names: Command Shell, Command Line Interpreter, Command Line Interface, Command Prompt etc etc.

It is quite possible that you have been exposed to various different shells especially if you work with Unix or Linux. The most common and popular shells are sh, csh, ksh, bash, zsh and fish…among many others.

A command shell has several advantages over a graphical interface and other software programs. It is extremely resource friendly which makes it very fast and efficient. Most commands supported by the shell are also very powerful in terms of the arguments and options supported.

Essentially all you need to know about shell is that you type in “one” command at a time in to the shell which the shell executes and prints out the output back onto the output. (you can execute more than one command using different techniques, but that is beyond this post). It then displays the prompt and waits for your next input or command.

So, How do you start a shell? Any time you log into a system remotely (for example using ssh or telnet) you get access to a shell. If you are already logged into a graphical environment, you start one as with other programs. This is where terminals come in handy…

Terminal Emulators

As useful as the command line shells are, you need an easy way to interact with them by typing commands from the keyboard. This is where the terminals or terminal emulators come in. Terminal emulators are programs provided by the desktop environments that allow you to easily interact with command shells.

If you use a desktop environment such as KDE or Gnome, you should already be familiar with one of these. Some examples of these are Konsole in KDE and gnome-terminal in Gnome. Other DEs such as XFCE has one named Terminal, while Enlightenment has Terminology and TWM has xterm.

Some of these terminal emulators provide additional functionality when interacting with the shell. These functionalities could be some thing like multiple tabs, copy-paste, bookmarks, themes or skins etc. You can pretty much use any of the terminal emulators depending on your preference for its functionality.

You can usually start the terminal emulator from the start menu that comes with most environments. In KDE, you will find the Konsole listed as an application in the System sub-menu in Kstart Menu. Other distros have similar menus to open the terminal.

If you cannot access the graphical menu or interface, there are also several virtual terminals that run behind the graphical interface or X. You can access this interface by using the keyboard shortcut Ctrl+Alt+F1. Actually, there are six of these virtual terminals which can access with shortcuts ranging from Ctrl+Alt+F1 to Ctl+Alt+F6. These come in handy when the graphical interface becomes unresponsive.

You can close the terminal and/or the shell by using the window close option of the terminal. You can do this as you do with any other program: by clicking the x (cross/close) button on the right hand corner, using the menu option File->Quit/Close or using the keyboard shortcut (usually Alt+F4).

In addition to this, you can close (actually exit) the shell itself by executing either the exit command or Ctrl+d. The Ctrl+d shortcuts actually logs you out of the shell.

Getting yourself familiarized with the command shell and the terminal will help you learn Unix systems much faster and easier than when you use graphical programs. You can learn some the easiest commands to master in Linux which are quite useful when working with Linux systems.