Terminal Basics

This article is aimed at people new to Ubuntu and linux in general. It will give you some background info about what a terminal is (and what a shell is) and how to tweak your terminal's profile.

What Is The Terminal?

In Ubuntu, running the default terminal application will start gnome terminal which is an emulator. There are other terminal emulators which you can use such as xterm. A terminal emulator is a pseudo terminal that is used to provide an environment from which you can interact with a piece of software called the shell. This pseudo terminal is present on the file system as a pts device in the /dev/pts directory. The terminal gives you access to a command prompt for a shell interpreter i.e. the "shell prompt" or "command line".
This command line is used to issue commands (run programs, run scripts). Note that the terms utility, program, and tool are often used interchangeably when talking about what can be run from the command prompt.

So to recap running the terminal application provides you with a virtual environment called a pseudo terminal (represented by a pts device in your file system under /dev/pts) which is running a shell that allows you to issue commands at its prompt.

At this point, some of you may be wondering "if these pseudo terminals are pts devices, what is a tty device is used for". First of all a pts device is actually a pseudo tty device. A tty device represents a virtual console, for example a command line at the text only operating level (e.g. runlevel 2 or 3) uses a tty device. You can still login to your system via 6 virtual consoles by pressing one of Ctrl+Alt+[F1...F6]. These virtual consoles are represented as devices tty1 through to tty6 in /dev on your file system. NB: you can get back to your graphical display by pressing Ctrl+Alt+F7.
Just in case you're not confused a little, another type of tty device that you may come accross are serial devices, for example a serial port on your machine could be represented as /dev/ttyS1 in your file system (Note the capital S for "serial" in the name).

Opening a Terminal

In Ubuntu, Ctrl+Alt+t will open a default terminal for you. Alternatively, you can start typing "terminal" into the dash as shown in the image below to see some of the terminals that are installed on your box.
Lots of other terminal implementations are available to install.


The default shell interpreter is BASH (Bourne again shell).
Generally speaking, bash includes all the best features from other shells plus more, so for new users there should be no reason to use anything other than the bash shell. There are other shells available including dash (implementation related to the bourne shell aka sh), ksh (the Korn shell), csh (the c shell), tcsh (enhanced csh) and zsh (the z shell).
These days, you'll often see the terms command line, terminal, shell, shell prompt, command shell, command language interpreter, bash prompt, bash shell (and others) used interchangeably (rightly or wrongly so they're all just referring to the text box where you enter commands!).

What Shell Am I Using? How Do I Change It?

You can see what shell is run for you when you login by taking a look in /etc/passwd and searching for your user name. Your entry will probably contain /bin/bash at the end of the line indicating that BASH is used. For example:

Note that the different fields are delimited by a colon. In this case, the field we're interested in is the last one.
To change your default shell, just replace this "/bin/bash" to the path of the shell you want to use.
To find out more about BASH read this post.
Note that other non human users use /bin/sh (which is a symbolic link to /bin/dash) or /bin/false. When /bin/false is used, no shell is allowed - so no login is possible.

Isn't the shell just old hat?

No, the granularity of control that can be achieved using the shell is a lot more than any gui can provide. So any serious "power user" should be very comfortable using the shell because it allows you to be far more productive at certain tasks (drawing pictures not being one of them!). People coming from a microsoft windows background will be familiar with the dos prompt. Don't confuse that with a unix/linux command shell. The unix/linux shell is far more powerful with a much richer and complete set of commands and utilities at your disposal.
Through the use of a shell, the command line provides a means to cut out some of the overhead introduced by a graphical user interface (GUI). For those who know exactly what they want to do, the command line can be used to accomplish tasks much more quickly than navigating through several levels of a GUI's menu to trigger some functionality. One could argue that the command line gives you an extra layer of control, putting you a step closer to the underlying system.

Configuring The Terminal's Profile

The default profile is called "Default", you can change this if you like. You can also add more profiles that you can switch between as you'll see in the next paragraph. Once you've got a terminal open and in focus you can tweak the look and feel (plus behaviour) of your terminal by changing its profile. To do so, move the mouse to the top menu and click on "Edit", then on "Profile Preferences". As shown in the image below: (Or you could press the right mouse button while over the terminal, then hover over "Profile" before selecting "Profile Preferences". You can see this menu route in "Adding New Profiles" section below which shows how to switch profiles).
Once you've selected "Profile Preferences", you'll get various options from changing the colour and background to extending the amount of scroll available. The image above shows you where the checkbox is on the profile's "Scrolling" tab for setting a larger scrollback, which can come in handy if you want to check on some output that happened earlier in your terminal session (The default is 512 lines).

Adding New Profiles

You can easily add new profiles by clicking on "Edit", then "Profiles..." in the top menu then clicking on the "New" button in the window presented.
You can then switch to your new profile either by clicking "Terminal" followed by "Change Profile" or pressing the right mouse button while over the terminal and hovering over "Profile" and selecting the desired profile from the options as shown in the image below.