Terminal, Shell, TTY, and Console are terminologies that are often confusing and loosely used to mean the same thing. But it’s hardly the case. There are nuanced differences that exist between each of these components.
In this guide, we flesh out the differences between these terminologies as they are used in UNIX/Linux systems.
A terminal is an environment that accepts text input and displays the output of the command executed. In a nutshell, it’s a text input/output environment, which allows you to run a shell and execute commands.
A terminal window is a text-only window that allows you to run commands in a shell. It is also synonymously referred to as a terminal emulator.
A console is a physical terminal or device with panels and computer controls, which facilitates interaction with the system by providing access to the terminal. To put this into context, a console usually comprises a keyboard and mouse in a traditional PC. These are then plugged into the main system in order to issue commands to the operating system.
Other examples of consoles include gaming consoles such as Xbox and PlayStation.
A Shell is a command-line interpreter. It is an environment that allows you to run programs and shell scripts and display the output on the terminal. A shell sits between the user and the kernel and is responsible for the execution of commands and control management.
If you are logging into a headless system or server, the shell is the primary interface that you see once a connection is established. Examples of widely used shells include Bash shell (/bin/bash), Korn shell (ksh), Z Shell (zsh), and PowerShell in Windows systems.
To know the type of shell you are running, run the following command:
$ which $SHELL
From the following output, you can see we are running the BASH shell.
TTY – Teletypewriter
TTY is an acronym for Teletype. It is derived from the Teletypewriter which is an obsolete electromechanical device used for typing and sending messages in the 1800s.
In Linux/UNIX, TTY refers to a standard terminal device such as the console that is attached to your server. Essentially, it is a device that lets you interact with the system by inputting data and viewing the output.
To check the TTY number you are currently connected to, run the w command
PTS – Pseudo Terminal Slave
PTS (Pseudo Terminal Slave) is a session used when connecting to another Linux system via SSH or using an SSH client such as Putty. To list the currently active PTS sessions on your system, again, run the w command, which lists both the tty number as well as the PTS remote connections.
The following output displays the default TTY session (tty7) and a PTS connection (pts/1) which is a remote SSH connection to the Linux system.
In this guide, we have drawn comparisons between Terminal, Shell, TTY, and Console. It’s our hope that you can comfortably distinguish these four components.