2

From what I know it seems that there are many ways to access the shell on Linux. So far the methods I know are:

  1. To use a program such as Terminal or Konsole
  2. To use the shortcuts CTRL + ALT + F1-6
  3. To disable X and boot straight into the command line
  4. To SSH in
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Grenville
  • 156

3 Answers3

9

(1) gives you an emulation of the terminal. Programs such as Gnome Terminal an Konsole are called "terminal emulator".

(2) gives you a real terminal. Alright, it's still an emulation of a terminal, but it's "more real" than (1), because the emulation is done by the kernel itself.

(3) is actually the same as (2). When you don't have X you will see tty0, which is what you get when using CtrlAltF1.

(4) is a remote shell, which is meant to be used from outside of the machine. To use SSH, of course you need to have a network connection to the machine.

Essentially all the methods are the same, you have a shell on the machine that can execute programs. There are subtle differences, for example:

  • Because a terminal emulator runs in a GUI, you can execute GUI programs from it and the GUI program will be opened in its own window.
  • Because SSH allows you to run programs in a remote machine, it allows you to do things when far away from the physical server.

You should see What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'? for more.

phunehehe
  • 20,240
  • 3
    (2) is not a real terminal, it is still a terminal emulation, but coming from the kernel itself (which is funny, because the Linux kernel evolved from a terminal emulator). This is a real terminal: http://en.wikipedia.org/wiki/VT100 – BatchyX Jan 12 '13 at 16:35
  • @BatchyX: thanks, I was about to write that. I've recently been considering how ‘terminal’ has lost its meaning these days. – Alexios Jan 12 '13 at 17:20
  • (4) technically, you can also use ssh locally i.e. without using a physical network connection. – jlliagre Jan 12 '13 at 21:51
  • @BatchyX Incorporated :) – phunehehe Jan 13 '13 at 08:49
2

There are some minor differences between these ways.

One is when you launch a terminal emulator (your Terminal and Konsole examples), you are already logged in while with the other methods (2,3 and 4), you need to login first and commonly provide a password. This is called a login shell.

Another difference would be the kind of terminal emulated which might (and likely will) vary between at least the (virtual or not) consoles and the terminal emulators (Terminal, Konsole). ssh will use whatever terminal you are already in when launching it (might be settable if you are connecting from a graphical client like putty). Mouse usability (copy/paste) might also be unavailable in console mode.

Ssh might tunnel X11 so will allow you to launch graphical applications like the terminal emulators. With the consoles, there won't be a visible graphical environment, although nothing forbids to launch X11 clients on servers displayed elsewhere.

An out of trend way to access the shell you didn't mentioned is login in through a serial line.

jlliagre
  • 61,204
  • Note that on the other end, ssh starts a separate shell which uses its own ("pseudo") terminal. – goldilocks Jan 12 '13 at 15:14
  • @goldilocks ssh uses the terminal emulator from where it is launched, not a specific one. Don't confuse the pseudo-tty and the emulator. – jlliagre Jan 12 '13 at 15:42
  • @jilliagre : I'm not confusing them, I was referring to the pt ('p'seudo-'t'erminal) on the remote system. Look in /dev/pts -- that's where the devices used by both local terminal emulators and remote logins are. Your local emulator uses one, then on the remote machine sshd uses another. – goldilocks Jan 13 '13 at 12:41
  • @goldilocks. You wrote ssh uses its own pseudo terminal so I guessed your comment was about my statement about ssh using the same terminal from where you launch it. I didn't mentioned the kind of device the shell is using to attach to the terminal emulator. It can indeed be a ttyx, a pts/x, a ttySx or possibly something else but that doesn't make that much a difference as far as the user is concerned. – jlliagre Jan 13 '13 at 14:38
  • "ssh uses whatever terminal you are already in" is ambiguous and could imply that the remote shell is running on the same device as the local ssh instance, which it is not. I'm sure that's not what you meant, but I just wanted to underscore the fact that the terminal device (pseudo, virtual, whatever) on the remote end is not the same as the terminal device you start ssh from. – goldilocks Jan 13 '13 at 14:50
  • @goldilocks Granted. My paragraph is talking about the "kind of terminal emulated" so there should be not that much ambiguity. – jlliagre Jan 13 '13 at 17:04
2

A shell is a program which processes shell commands (in the shell's language) from input and which can instruct the operating system to execute other programs in various ways. It can do this in an interactive context by working with a virtual device; on linux these are represented either by pre-existing /dev/tty[N] nodes for VT's or dynamically created nodes /dev/pts/[N] for everything else. A "VT" is a Virtual Terminal, and those are the non-GUI consoles you can access via your methods #2 and #3. With regard to #1 (Konsole, etc.), these are called terminal emulators (so beware the difference between a "terminal emulator" and a "virtual terminal"). VT's are sometimes called VC's ("virtual consoles").

A shell is not always interactive, however; the system uses shell incarnations to do a lot of business. Keep in mind that there is not just one instance of the shell running that you access via whatever method; generally, each point of access is a different instance. So you might distinguish between "the shell" (abstractly, the program that serves this purpose for the system) and "a shell" (one instance of that program).

goldilocks
  • 87,661
  • 30
  • 204
  • 262