2. The Terminal

$Id: terminal.xml 1404 2009-01-08 00:47:04Z rafi $

Table of Contents

2.1. The Shell

The terminal or console is a text based interface to the operating system. It does not feature graphical widgets, so you need to type in the commands using the keyboard only. There is however a small difference between a terminal and a console. A console is directly attached to the computer, a terminal can be opened over the network or in a similar fashion. This difference does not affect the way you interact with the operating system. Therefore I will use those two terms interchangeably.

On FreeBSD and Linux you can switch from the graphical user interface, to the console by pressing simultaneously Ctrl+Alt+Fx where Fx is one of the F1 to F12 keys. Sun Solaris does not support switching from the graphical user interface to a console, so this key combination has no effect on Sun Solaris.

Example 1. Switching to the console on FreeBSD

You will be prompted to enter user name and password. After that, you're ready to use the console.

FreeBSD/i386 (penny.example.org) (ttyv0)


If you do not want to leave your graphical user interface, you may open a terminal. It is likely that you will find an entry for a terminal somewhere in the menu of the graphical user interface.

It is possible to open a terminal on a remote UNIX system. Type the following command in a terminal

$ ssh username@hostname

Replace the username with your user name on the remote system and hostname with the host name of the remote host. For instance,

$ ssh joe@penny.example.org

As you can see, you will be prompted to enter the password for the user name you specified.

The above command will only work for remote system allowing SSH Connections (SSH stands for “Secure Shell”). In earlier days of UNIX, there were several other ways to connect to a remote system, telnet, rsh etc., to name only a few, but they were all insecure. They transmit your password unencrypted over the wire, so it is possible for anybody to read it.

2.1. The Shell

The shell is the program that lives inside a terminal and takes commands from you. As every where in the UNIX world, there is more than one way to do things, and so there exist many shells. The bash shell is the default shell on most Linux systems. FreeBSD favors the tcsh shell (tcsh stands for “Tenex C-Shell”). Sun Solaris uses sh (sh simply stands for “Shell”, on which bash is based on), and ksh (“Korn Shell”).

All shells provide a prompt (also known as command line). This is the place you enter commands. Depending on the shell and its configuration, the prompt may appear differently, but always serves the same purpose.

Example 2. Different prompts

A simple sh prompt


Default bash prompt


A customized tcsh prompt

jack@salma ~/unixsurvivalguide>

Bash, ksh, and tcsh shell have a nice feature called file name completion. File name completion allows you to enter some portion of the command or file name and make the shell complete the rest. By default, the bash shell invokes file completion if you press the Tab key. Tcsh needs you to press the Ctrl+D, and ksh Alt+Esc in order to invoke the file name completion. If the portion to complete is ambiguous, they will show a list of possible completions as shown in the following example

Example 3. File name completion

$ ema
emacs             emacs-chooser     emacsclient
emacs-athena-22.1 emacs-gtk-22.1
$ ema

To leave the terminal, you can type in logout, or if that doesn't work because you are not in a login shell (UNIX will tell you if you try logout) type exit. A short-cut is always using the key combination Ctrl+D (yes, it's the same key combination as used by the tcsh for command completion, so you have to be careful when using this combination in a tcsh shell).