What is the difference between "Shell" and "Terminal"?

8

3

I am fairly new to Ubuntu and I am loving it!

But I don't quite understand the difference between the shell and the terminal. Can any one explain? Someone told me that a terminal is just a "tool" to view the shell, akin to using a browser like Firefox or Chrome to "view" the web.

Is his analogy correct? Also what is the default shell of Ubuntu? Bash, tcshell, or something else?

smilingbuddha

Posted 2010-11-12T02:59:48.153

Reputation: 1 591

Question was closed 2015-02-23T18:12:33.310

1You can usually find out what shell you're using with echo $0. – Greg Hewgill – 2010-11-12T03:06:33.843

Answers

9

That's not a bad analogy at all. A terminal can be considered as just a device to display information and receive it. It can range from a dumb terminal which does nothing but interpret printable characters, to a behemoth with full cursor positioning and colour capabilities.

A shell, which often (but not always) runs in a terminal, is a powerful environment for interpreting commands and acting on them. You can consider most modern shells to be full-blown programming languages.

The basic idea behind an interactive shell is to accept those commands from the user (via the terminal) and act on them, either by doing its own stuff or running external programs to do it. A non-interactive shell is the one that generally runs pre-written scripts to perform tasks. Quite a few shell scripts will run without a terminal, since they have no need of user interaction.

Ubuntu's default shell is bash, although it's easy to change it to whatever you want.

user53528

Posted 2010-11-12T02:59:48.153

Reputation:

is it really fair to call a shell a programming language? It is true that a shell will require very specific syntax for use, but I don't think that makes it a programming language. Could you elaborate? – ubiquibacon – 2010-11-12T07:09:56.323

5@typoknig, sure, when you can do things like for i in {1..5}; do echo $i; done, it's a programming language, no real different from Perl/Python. Even cmd.exe is a programming language, albeit a fairly limited one compared to bash et al. If it weren't a programming language, what the heck have I been writing my scripts in for the last 25+ years? :-) – None – 2010-11-12T07:16:04.773

9

The shell is a program which accepts your commands (ls, cd, etc) and processes them by running built-in functions (like cd) or calling external programs (like ls or gcc).

The terminal is the thing (almost always a program these days, but often a piece of hardware back in the bronze age) that manages your keystrokes and shows text to you---both the bits you type and the bits the shell or another program returns to you. When the terminal is a GUI program it draws the nice graphical window, tells X what font to use, calls the text drawing routines and so on. In the old days it might have been little more than a fancy electric typewriter with fan-fold paper.

dmckee --- ex-moderator kitten

Posted 2010-11-12T02:59:48.153

Reputation: 7 311

6

That is correct. The terminal emulator provides graphical handling for displaying a window, menu, etc. and text output, along with input via keyboard (and mouse, under certain conditions) to command-line programs.

The shell provides a flexible command line for input of commands to be executed, along with feedback on things such as the current directory, the superuser status, and so on.

The current default shell for Ubuntu is bash.

Ignacio Vazquez-Abrams

Posted 2010-11-12T02:59:48.153

Reputation: 100 516

2

The default shell in Ubuntu is bash. Also, the shell is a program that you use to interact with the system (one of many ways to do this). By terminal, you mean a 'terminal emulator'. A terminal emulator could be considered a 'fake monitor', if you will.

Radhesh

Posted 2010-11-12T02:59:48.153

Reputation: 201

1

Back in the old days, when computers were more expensive than a house, they were called mainframes. Computing was expensive, and still many people needed access. The solution? Terminals!

These were "dumb" computers, nothing more than a screen with a keyboard and a very basic computer. The terminal had a permanent connection to the mainframe. Commands were processed by the mainframe which returned results back to (the display of) the terminal. Most of what you did was text based, no graphics, no mouse, so all the terminal had to do was send and receive text, and display it on the screen.

If you take Chrome OS, or if you take a modern browser with a permanent internet connection and someone who does everything in the cloud, you get more or less the same idea. So your analogy of the browser is in fact very good.

Wikipedia says that a shell is a user interface to a computer, and it can be graphical as well. MS Windows is a shell. The UNIX or Linux shell is a CLI, commandline interface. Again, your browser analogy works here as well, with the webpage as the interface to the website and its database.

SPRBRN

Posted 2010-11-12T02:59:48.153

Reputation: 5 185

0

The default shell in Ubuntu from 6.10 and up is Dash: https://wiki.ubuntu.com/DashAsBinSh

Vic

Posted 2010-11-12T02:59:48.153

Reputation: 101

For programs invoking /bin/sh, yes. The default shell for users is still bash. – Ignacio Vazquez-Abrams – 2010-11-12T03:05:07.923

Ah-- my bad. I spend my days in CentOS. – Vic – 2010-11-12T03:05:42.503