Unix Manuals

Unix Tutorials

NOTICE - New forum for all UNIX learners, users and programmers - click here

Using the Shell

Before starting this page of the tutorial, ensure that you are logged in. Refer to the section Logging In if you need guidance for this.

When you are logged in, you see a prompt. This may be a dollar sign, a hash sign, or even some text. Examples are:

$

#

london-pro>

Throughout this tutorial, we'll use the dollar sign as the prompt. Whatever your prompt symbol is, it means the same thing: the system is prompting you to give it a command. First, just try hitting return a few times. You will see that each time you hit return, the prompt is displayed again:

$
$
$

We will now try some basic commands, just to get the feel of the way the system works. Let's start by asking the system for the current date and time. The command to do this is simply 'date'.

$ date
Tue Feb 20 11:28:18 GMT 2001
$

(As always in this tutorial, the command you enter is shown in bold. Everything else is the system's response). Don't worry about remembering the specific commands at this stage - we're just trying to get used to the way the system responds.

There are a few things to notice here. Firstly, when we typed 'date', it appeared on the screen just after the prompt. Nothing happened until after we pressed RETURN or ENTER after the 'date' command. The RETURN or ENTER key says to the system, "I've finished typing my command, now go and process it, and come back to me with a response". The system does just that. It checks to see if it recognises the command. If it does, it processes it. This is often known as 'running' the command. Many commands produce some sort of response (known as 'output' from the command). In this case, the 'date' command produces some output: the current date and time.

After you hit RETURN or ENTER, the system runs the command, and the output is displayed. Then, if the command has finished, the prompt is displayed again, ready for your next command.

If you run another command, your old command and its output will still be visible on the screen for a while. For example, run the 'date' command again. You will get a new date and time (which should be a few seconds or minutes later than the previous one, of course). You will still be able to see the previous 'date' command and its output on the screen. For example, your screen may now look like this:

$ date
Tue Feb 20 11:28:18 GMT 2001
$
date
Tue Feb 20 11:32:17 GMT 2001
$

Let's try a different command: 'hostname'. This command asks the system to tell us its name - this can be useful if you use more than one system, and get confused about which one you are using! If you run it, your screen will look something like this:

$ date
Tue Feb 20 11:28:18 GMT 2001
$
date
Tue Feb 20 11:32:17 GMT 2001
$
hostname
london-pro
$

The output of the 'hostname' command is the name of the system you are using, which will have been set up by your system administrators.

Your screen can only fit so many commands and their output on it. Eventually, old commands will start to 'scroll off' the top of the screen.

Let's try one more command: 'clear'. This command clears your screen, and removes all previous commands and their output, leaving you with just the prompt:

$

When you interact with the system in this way, you are actually interacting with the 'shell'. The shell's job is to take commands from you, and pass them onto the central part of the UNIX system. When the UNIX system responds to the command from the shell, the shell passes the response back to you, by displaying it on your screen. The shell is like an interpretter, translating commands you give it ready for use by the system, and translating the system's response back to you. This concept of a 'shell' can be difficult to understand at first, but for now it really doesn't matter. You have already learned how to make requests to the system, and see the responses.

By now, you will be ready to see some more useful commands, and learn about how the system can help you to store and organise your data.

This may be a good point at which to have a break. Bookmark this page in your browser, so you can come back to it later on. When you are ready, we will move on to look at some more useful commands.

Creating a simple file using the 'vi' editor

Back to 'Unix Tutorial' Table of Contents

Home


© Copyright 2000-2003, Tom Reader, All Rights Reserved.
UNIX is a registered trademark of The Open Group in the US and other countries.
For more information on the use of the UNIX trademark, click here.
The contents of this site are not connected with or endorsed by The Open Group in any way.