The Question :
248 people think this question is useful
I noticed many mentions of
tty in some open source projects, could someone tell me what do they mean and what is the difference between them?
The Question Comments :
The Answer 1
236 people think this answer is useful
“tty” originally meant “teletype” and “pty” means “pseudo-teletype”.
In UNIX, /dev/tty* is any device that acts like a “teletype”, ie, a terminal. (Called teletype because that’s what we had for terminals in those benighted days.)
A pty is a pseudotty, a device entry that acts like a terminal to the process reading and writing there, but is managed by something else. They first appeared (as I recall) for X Window and screen and the like, where you needed something that acted like a terminal but could be used from another program.
The Answer 2
245 people think this answer is useful
A tty is a terminal (it stands for teletype – the original terminals used a line printer for output and a keyboard for input!). A terminal is a basically just a user interface device that uses text for input and output.
A pty is a pseudo-terminal – it’s a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a “real” terminal, it transfers the input and output to another program.
For example, when you ssh in to a machine and run
ls command is sending its output to a pseudo-terminal, the other side of which is attached to the SSH daemon.
The Answer 3
23 people think this answer is useful
tty: teletype. Usually refers to the serial ports of a computer, to which terminals were attached.
pty: pseudoteletype. Kernel provided pseudoserial port connected to programs emulating terminals, such as xterm, or screen.
The Answer 4
19 people think this answer is useful
If you run the mount command with no command-line arguments, which displays
the file systems mounted on your system, you’ll notice a line that looks something
none on /dev/pts type devpts (rw,gid=5,mode=620)
This indicates that a special type of file system, devpts , is mounted at /dev/pts .This
file system, which isn’t associated with any hardware device, is a “magic” file system
that is created by the Linux kernel. It’s similar to the /proc file system
Like the /dev directory, /dev/pts contains entries corresponding to devices. But
unlike /dev , which is an ordinary directory, /dev/pts is a special directory that is cre-
ated dynamically by the Linux kernel.The contents of the directory vary with time
and reflect the state of the running system.
The entries in /dev/pts correspond to pseudo-terminals (or pseudo-TTYs, or PTYs).
Linux creates a PTY for every new terminal window you open and displays a corre-
sponding entry in /dev/pts .The PTY device acts like a terminal device—it accepts
input from the keyboard and displays text output from the programs that run in it.
PTYs are numbered, and the PTY number is the name of the corresponding entry in
example, if the new terminal window’s PTY number is 7, invoke this command from
% echo ‘I am a virtual di ’ > /dev/pts/7
The output appears in the new terminal window.
The Answer 5
6 people think this answer is useful
tty is a physical terminal-teletype port on a computer (usually a serial port).
The word teletype is a shorting of the telegraph typewriter, or teletypewriter device from the 1930s – itself an electromagnetic device which replaced the telegraph encoding machines of the 1830s and 1840s.
TTY – Teletypewriter 1930s
pty is a pseudo-teletype port provided by a computer Operating System Kernel to connect software programs emulating terminals, such as ssh, xterm, or screen.
PTY – PseudoTeletype
A terminal is simply a computer’s user interface that uses text for input and output.
These use pseudo-teletype ports however, their naming and implementations have diverged a little.
Linux mounts a special file system devpts on /dev (the ‘s’ presumably standing for serial) that creates a corresponding entry in
/dev/pts for every new terminal window you open, e.g.
macOS/FreeBSD also use the /dev file structure however, they use a numbered
TTY naming convention
ttys for every new terminal window you open e.g.
Microsoft Windows still has the concept of an
LPT port for Line Printer Terminals within it’s Command Shell for output to a printer.