Shell, Console - the basics

Tuesday, 17 March 2009, adz

In this article we’d like to present the basic concepts needed to navigate the console world. We are going to find out what a shell is all about, what is a terminal, and what the famous console is actually for.

The Good, the Bad and the Ugly *)

The Shell, the Terminal, and the Console. These words are very often used interchangeably to describe the textual mode of interacting with the system or Command Line Interface (CLI), also known (incorrectly) as “character user interface” (CUI). Really, the differences between them are today more and more blurred. The notions derives from the times when Personal Computers weren’t so much popular as they are today, and when the King of the hill was a Unix system run on a mainframe beast.

  • Shell - a layer or a part of an operating system, sometimes called interpreter. Shell is a specialized interface which intercedes between a user and a system’s kernel (this being the operating system’s core). It is an environment which creates suitable conditions to run applications. We can distinguish two types of shells: graphical ones, like Windows Explorer or Finder (found in Mac OS X), and textual ones - e.g. bash, sh, tsh, csh, zsh and the like.
  • Terminal - input/output device (hardware) connected to a central computer which allows users to interact with the computer. It is destined to enter commands and to display results of the commands in return. Back in the medieval times of IT, it was a teletype machine with a printer attached which functioned as a terminal. The monitors and keyboards, as we now know them, became feasible and popular several years later.
  • Console - a system administrator’s terminal. It is worth mentioning here that terminal devices, their availability and their costs had enormous impact on development of Unix systems. First terminals were slow and the programmers had to write short programs which generated rather small amount of data. Thanks to this the KISS rule (Keep it simple stupid!) was born which championed the struggle to achieve simple, and where possible, elegant, solutions. Programs take data in the form of short text messages. Thanks to this commands can be arranged with the help of pipes or redirects to or from a file with the help of mighty regular expressions.

Bash

Bash is one of the many shells available for the whole family of Linux systems. Sometimes it is called ‘Bourne again shell’ in honor of Steven Bourn who developed the classic sh shell. Bash is backward compatible with the sh shell. One of the most important feature of all shells is that most of their commands are actually small standalone programs which can be found within the directory tree. Bash, too, is a program which in Linux is placed in the /bin directory (/bin/bash). (Solaris - /usr/bin/bash, FreeBSD and OpenBSD - /usr/local/bin/bash, NetBSD - /usr/pkg/bin/bash). Some of the shell commands are built into the shells themselves e.g. cd, break, exec.

System shells make extensive use of input/output streams:

  • stdin - standard input stream, standard input channel which transfers data to the computer, by default data are retrieved from a keyboard,
  • stdout - standard output stream, standard output channel, where input command’s results generated by the computer are being moved to, or where a program writes its data; by default the data are moved to monitor’s screen,
  • stderr - standard error stream, data stream to which program’s error messages are written to, by default it is monitor’s screen.

A user’s session running Bash shell is shown below. As a prompt character the dollar character is uses $. The user may enter his command after it.

adz@laptop:~$
[adz@laptop /]$
$

In the case of the root account the prompt sign changes to #.

root@laptop:~#
[root@laptop /]#
#

None of the examples we make use of in this article will require superuser permissions (rights) unless otherwise stated.

*) A “Spaghetti Western” movie starring Clint Eastwood - The Good, the Bad and the Ugly.

This article is part of the Command line tricks series. Go further to the next article: File management in Linux »

Translated by P2O2, Proof-read by trashcat and chaddy

Subscribe to RSS feed for this article!

Comments

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)

You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>