a) Introduction to the Linux Shell

The shell has been the major interface for the Unix/Linux operating system since it was first conceived. The shell allows interaction with the operating system through a text based interface. The shell provides the user with the following features:

  • An easy to use command line interface (CLI)
  • Combine existing tools to create new tools
  • Input/output redirection
  • Wildcard characters for filename abbreviation
  • Variables and options for environment customisation
  • Ability to write shell functions and programs
  • Command-line editing
  • Command history (quick access to previous commands)
  • Arithmetic
  • Command abreviations

The user starts the shell by logging into the computer with a userid and password

Logging in
******************************************************************************
***                   THE UNIVERSITY OF YORK IT SERVICES                   ***
***                                                                        ***
***                       THIS IS A PRIVATE COMPUTER                       ***
***                UNAUTHORISED ACCESS STRICTLY PROHIBITED                 ***
******************************************************************************

login: user001
password: 
Last login: Mon Sep  8 14:12:44 2014 from gallifrey.york.ac.uk
-bash-4.1$


The last line is a command prompt and it is the means by which the computer is telling you that it is ready to accept a command from you. If you do not see the prompt, the computer is probability still executing the last command you have typed. The user types commands which take the form:

command [ options ] [ arguments ]

Options to a command are usually proceeded by a '-' or '- -', this differentiates them from the arguments. The following example shows the echo command which prints the arguments and the ls command which take options arguments. The ls command display the users file. There will be more explanation of files and the ls command later.

Exmaple of command execution
-bash-4.1$ echo Hello World
Hello World
-bash-4.1$ ls
bin  Chemistry  Desktop  examples  Experiments  intel  jobs  logs  tmp
-bash-4.1$ ls -l
total 296
drwxr-xr-x 2 abs4 csrv        4096 Jun 24 09:39 bin
drwxr-xr-x 3 abs4 csrv        4096 Jun  6 09:23 Chemistry
drwxr-sr-x 2 abs4 elecclust   4096 Mar 11 10:53 Desktop
drwxr-xr-x 3 abs4 csrv        4096 Jun 30 12:21 examples
drwxr-xr-x 5 abs4 csrv        4096 May 23 11:34 Experiments
drwxr-xr-x 3 abs4 csrv        4096 Aug 14 12:26 intel
drwxr-sr-x 3 abs4 elecclust   4096 Aug 15 12:49 jobs
drwxr-xr-x 2 abs4 csrv      266240 Aug 15 13:48 logs
drwxr-xr-x 3 abs4 csrv        4096 Aug 14 14:50 tmp
-bash-4.1$ 

To logout of the shell type logout, exit or <CTRL>D

Logging out
-bash-4.1$ exit
logout
Connection to ecgberht closed.

 

The are a number of shells available to the user. In this tutorial we will be using BASH, the most widely used Linux shell.