Lesson 26 of 29 ↓
- 1.Rhel 9 Administration Guide
- 2.Ubuntu Boot Process Guide
- 3.Linux Basic Commands Guide
- 4.Comprehensive Unix Shells Guide
- 5.Mastering Vim Deep & Practical Guide
- 6.Magic Numbers in Linux Deep Systems Guide
- 7.Wildcards & Globbing in Linux Deep Cli Guide
- 8.Linux Users & Groups Deep Administration Guide
- 9.Journaling in Linux Filesystems Deep Systems Guide
- 10.Getopt & Getoptlong Deep System-level Option Parsing Guide
- 11.Su Command in Linux Complete Guide with Environment Variables
- 12.Linux File Permissions and Ownership Complete Practical Guide
- 13.Ubuntu Package Management Apt Complete Guide
- 14.Bash Scripting Basics
- 15.Linux File System Essentials
- 16.Process and Thread Management
- 17.Session 10 : Introduction to Networking & the Application Layer
- 18.Linux Networking Cli & Introduction to Yocto for Machine Routing
- 19.Comprehensive Guide to Ssh (secure Shell)
- 20.Logical Volume Management (lvm) Guide
- 21.C Build Process & Libraries Guide
- 22.Archiving and Compression in Linux
- 23.Linux Package Managers: a Detailed Guide
- 24.Misra-c Guidelines Detailed Cheat Sheet
- 25.Mqtt Server Setup (pc as Server)
- 26.Detailed Explanation of Tty and Pts in Linux
- 27.Vim Cheat Sheet
- 28.Difference Between apt and apt-get
- 29.Difference Between apt Upgrade and apt Full-upgrade
7 min read
Detailed Explanation of Tty and Pts in Linux
What is Tty?
TTY originally stands for Teletypewriter. Historically, it referred to physical machines (keyboards + printers) used to interact with computers. Although physical teletypes are gone, the term is still used in Linux to describe kernel-managed terminals.
Modern Tty (linux Context)
In modern Linux systems:
-
A TTY is a virtual console managed directly by the Linux kernel.
-
Each TTY represents an independent login session.
-
You can switch between TTYs using:
Ctrl + Alt + F1 ... F6These are commonly mapped as:
-
/dev/tty1→ first virtual console -
/dev/tty2→ second virtual console -
and so on
Characteristics of Tty
-
Works without a graphical interface
-
Available even if X11/Wayland crashes
-
Ideal for system recovery and debugging
-
Each TTY runs a login service (usually
getty)
Common Tty Use Cases
-
Logging in when the desktop environment fails
-
Fixing display drivers
-
System maintenance and rescue mode
What is Pts?
PTS stands for Pseudo-Terminal Slave. It represents a software-emulated terminal used by terminal emulators and remote connections.
How Pts Works
A pseudo-terminal consists of two parts:
-
PTMX (master) → controlled by a terminal emulator or SSH
-
PTS (slave) → behaves like a real terminal to programs
When you open a terminal window:
-
The system allocates a new PTS device
-
Example devices:
-
/dev/pts/0 -
/dev/pts/1
-
Characteristics of Pts
-
Created dynamically when needed
-
Requires a terminal emulator or SSH session
-
Fully emulates a real terminal interface
-
Depends on user-space processes, not kernel virtual consoles
Common Pts Use Cases
-
GNOME Terminal, Konsole, Alacritty
-
SSH connections
-
Docker attached terminals
Key Differences in Architecture
| Feature | TTY | PTS |
|---|---|---|
| Managed by | Linux kernel | User-space + kernel |
| Creation | Static (boot time) | Dynamic (on demand) |
| Needs GUI | No | Yes (for local use) |
| Stability | Very high | Depends on emulator |
| Recovery safe | Yes | No (if GUI fails) |
Important Commands
Check current terminal:
ttyList logged-in users:
whoExample output:
-
/dev/tty2→ kernel TTY -
/dev/pts/1→ pseudo-terminal
Summary
-
TTY = Kernel virtual console (lowest level, most reliable)
-
PTS = Software-based terminal (flexible, user-friendly)
-
Both provide terminal interfaces but serve different layers of the system
Tty vs Pts Step-by-step with Real-life Analogy
Imagine a Big Office Building (your Computer)
-
The building = your computer (hardware + OS)
-
The security system + building rules = the Linux kernel
You have two ways to work inside this building:
-
Fixed desks in a control room → like TTYs
-
Flexible coworking spaces with laptops → like PTS
What is a Tty in This Analogy?
Fixed Control Room Desks (tty)
-
The building has several fixed desks in a control room.
-
Each desk has:
-
A chair (your session)
-
A fixed monitor + keyboard (direct input/output)
-
-
These desks are numbered: Desk 1, Desk 2, Desk 3, ...
In Linux:
-
These desks are virtual consoles:
/dev/tty1,/dev/tty2,/dev/tty3, ...
-
You move between them with:
Ctrl + Alt + F1..F6
Properties (why Theyre Special)
-
Always there as long as the building (kernel) is running
-
Do not depend on fancy equipment (no GUI needed)
-
Used by admins when something goes wrong
If the fancy office network dies, you still have the secure control room.
What is a Pts in This Analogy?
Flexible Coworking Laptops (pts)
Now imagine a large open-office space:
-
People sit anywhere with laptops.
-
Each laptop connects to the company’s internal systems over the network.
In Linux:
-
The laptops = terminal emulators / SSH clients (GNOME Terminal, Konsole, ssh)
-
Each time you open a terminal window, the system gives you a new virtual plug into the system:
-
/dev/pts/0 -
/dev/pts/1 -
/dev/pts/2
-
These are PTS devices = Pseudo-Terminal Slaves.
Properties
-
Created only when needed (when you open a terminal / SSH session)
-
Depend on software:
-
GUI (for local terminals)
-
SSH / container runtime (for remote / Docker)
-
If the GUI crashes, all these laptop sessions disappear — but the control room (TTYs) is still working.
Side-by-side in the Analogy
| Real-Life Analogy | Linux Concept |
|---|---|
| Building rules + security | Linux kernel |
| Fixed control-room desks | TTY (/dev/tty1, /dev/tty2, ...) |
| Laptops in coworking area | PTS (/dev/pts/0, /dev/pts/1, ...) |
| Sit at control-room desk | Switch TTY (Ctrl+Alt+F2) |
| Open a laptop terminal | Open GNOME Terminal / SSH |
| Desks exist even if power to Wi‑Fi goes | TTY works even if GUI/network is broken |
| Laptops useless if Wi‑Fi / network / power to routers fails | PTS dies if GUI/SSH/session dies |
When Do You Actually See Them?
-
Log in on a black full-screen console → you are on a TTY
ttycommand might show:/dev/tty2
-
Open GNOME Terminal / Konsole → you are on a PTS
ttycommand might show:/dev/pts/1
So:
-
TTY = fixed console inside the OS
-
PTS = software-emulated console via a program
Process Flow: Kernel → Getty → Shell → Gui → Terminal
Below is a simplified flow of what happens from boot to you typing in a terminal.
Boot and Kernel
-
You power on the machine.
-
Bootloader (GRUB, etc.) loads the Linux kernel.
-
Kernel starts and:
-
Initializes hardware
-
Mounts root filesystem
-
Starts PID 1 (usually
systemd)
-
[Power On]
↓
[Bootloader]
↓
[Linux Kernel]
↓
[PID 1 (systemd)]Systemd Starts Getty on Ttys
systemd (or older init) starts getty services on several TTYs:
-
getty@tty1.service -
getty@tty2.service -
...
Each getty is attached to a device like /dev/tty1.
[systemd]
├─ getty@tty1 → /dev/tty1
├─ getty@tty2 → /dev/tty2
└─ getty@tty3 → /dev/tty3getty is the program that:
-
Displays:
login: -
Waits for username
-
Hands control to
login/ PAM
Login and Shell on Tty
When you enter username + password:
-
getty+loginauthenticate you. -
On success, they start your shell (e.g.,
bash,zsh) on that TTY.
/dev/tty2
↓ (getty shows login: )
[login]
↓ (auth successful)
[bash / zsh shell]Now you are logged in on a TTY, directly talking to the kernel via the TTY device.
Starting the Gui From a Tty
From a TTY session (text only), you might run:
-
startx -
or a display manager is started by systemd:
gdm,sddm,lightdm, etc.
Flow:
[Kernel]
↓
[systemd]
↓
[gdm / sddm / lightdm (Display Manager)]
↓
[Desktop Session (GNOME / KDE / XFCE)]The display manager:
-
Shows the graphical login screen
-
After login, starts your desktop environment
Opening a Terminal Emulator (creating a Pts)
Inside the GUI (GNOME, KDE, etc.):
-
You open GNOME Terminal (or Konsole, etc.).
-
The terminal emulator asks the kernel for a pseudo-terminal pair:
-
Master: controlled by the terminal emulator program
-
Slave:
/dev/pts/Ndevice for programs to use
-
-
The terminal emulator starts your shell (bash/zsh) attached to the PTS.
[GUI Desktop]
↓ (launch)
[Terminal Emulator (e.g., gnome-terminal)]
↓ (requests pty)
[Kernel creates PTY pair]
├─ Master: handled by terminal emulator
└─ Slave: /dev/pts/0
↓
[Shell (bash/zsh) attached to /dev/pts/0]When you type:
-
Keystrokes → terminal emulator → PTY master → PTY slave → shell
-
Output from shell → PTY slave → PTY master → terminal emulator → drawn on your screen
Big Picture Diagram
┌───────────────────────────────────────────┐
│ Hardware │
└───────────────────────────────────────────┘
│
▼
┌──────────────────────┐
│ Linux Kernel │
└──────────────────────┘
│
▼
┌──────────────────────┐
│ systemd │ (PID 1)
└──────────────────────┘
│ │
TTY path │ │ GUI path
▼ ▼
┌────────────────┐ ┌───────────────────┐
│ getty@tty1... │ │ Display Manager │
└────────────────┘ │ (gdm / sddm ...) │
│ └───────────────────┘
▼ │
[login on TTY] ▼
│ [Desktop Session]
▼ │
[Shell on TTY] ▼
│
▼
[Terminal Emulator]
│
▼
[PTS /dev/pts/N]
│
▼
[Shell on PTS]Summary in One Sentence
-
TTY: direct login on kernel virtual consoles — exists even without GUI.
-
PTS: terminal sessions inside GUI or over network (SSH) using pseudo-terminals created on demand.
Comments
Loading the discussion…