What is a tty, and how do I access a tty?
tty is one of those funky Unix commands that prints the name of the terminal connected to standard input.
TTY’s are text-only terminals commonly used as a way to get access to the computer to fix things, without actually logging into a possibly b0rked desktop.
By default, Ubuntu has 7 tty’s.
- On Ubuntu 17.10 and newer: It’s GUI login screen on 1 , GUI desktop on 2 and command lines on 3-7 .
- Up until Ubuntu 17.10: 1-6 are command line only and 7 runs your X session (your normal desktop).
To access them, use this keyboard shortcut:
Ctrl + Alt + F3 (or F1 until 17.10).
Changing F3 to F3-F6 to access the terminal that you want.
To get back to your GUI session (the normal desktop):
Ctrl + Alt + F2 (or F7 until 17.10).
Sir you have mentioned » to F1-F6 to access the terminal that you need» , how they are different and how to use them as per to need ,what kind of need is supported to which terminal. I dont know if it is the right place but your question and answer pointed it for me.
I offer this answer, I aimed to represent this potentially confusing topic with enhanced clarity: askubuntu.com/a/1329549/1157519
A tty, short for teletype and perhaps more commonly called a terminal, is a device which lets you interact with the system by sending and receiving data, such as commands and the output they produce.
There are many kind of ttys, but nowadays most ttys are implemented in software, such as the graphical consoles you can access with Ctrl+Alt+Fn, or terminal emulators such as Gnome terminal that run inside an X session.
There is also a tty command, which shows the device node of the terminal in which it is running (or prints «not a tty» if it is not running inside a terminal; yes, it is possible to run commands outside a terminal). For example:
firas@itsuki ~ % tty /dev/pts/0 firas@itsuki ~ % ssh localhost tty not a tty
When I am logged in and running a shell on the machine, the shell is normally running inside a terminal, namely here it is /dev/pts/0 . However, when I run ssh host command to run a command on a remote host, the command is not run inside a terminal.
What is TTY in Linux?
Sooner or later, you’ll come across the term tty while using Linux. Learn what it is and what is its significance.
You must have heard about the term “TTY” when it comes to Linux and UNIX. But, what is it? Is it useful to you as a desktop user? Do you need it? And, what can you do with it? In this article, let me mention everything essential to get you familiar with the term TTY in Linux. Do note that there’s no definitive answer to this, but it relates to how input/output devices interacted in the past. So, you will have to know a bit of history to get a clear picture.
History Behind the Term ‘TTY’
It all starts with a Teleprinter in the 1830s. Teleprinters let you send/receive text messages over the wire. It was a replacement to Morse code communication, where two operators were needed to effectively communicate with one another. And, a Teleprinter just needed a single operator to easily convey a message. While it did not have a modern-layout keyboard, its system was later evolved by Donald Murray in 1901 to include a typewriter-like keyboard. The Murray code reduced the effort for operators to send a message. And, this made it possible for a Teleprinter to evolve as a commercial Teletypewriter in 1908. TTY is shorthand for Teletypewriter. The difference between the Teletypewriter and a regular typewriter was that a Teletypewriter was attached to a communication device to send the typed message. Teletypewriter made it possible for humans to communicate faster over a wire without any computers until now. And, this is where “TTY” came into existence.
The (relatively) Modern Concept
Now, you must be wondering, how did it land into modern computing and in Linux? Well, for starters, when Teletypewriter hit the market, some years later semiconductor transistors were developed which then evolved into microprocessors making a computer possible. Initial computers didn’t have the concept of a keyboard. Punch cards were the input method. While computers were evolving, batch input cards were eventually replaced by Teletypewriters as a convenient input/output device. With technological advancements, the Teletypewriters were ‘virtualized’ using electronics. So, you wouldn’t need a physical, mechanical TTY, but a virtual, electronic TTY. Earlier computers didn’t even have video screens. Things were printed on paper instead of displaying on a screen (which didn’t exist). And hence you see the use of the term ‘print’, not ‘display’. Videos were added to terminals later as technology advanced. In other words, you might have heard of them as video terminals. Or, you could call them “physical” terminals. And, then these evolved into software emulated terminals which came with enhanced abilities and features. This is what you call a “terminal emulator”. For instance, GNOME Terminal, or Konsole, are some of the best terminal emulators that you will find for Linux.
So, What is TTY in Linux?
When it comes to Linux, TTY is an abstract device in UNIX and Linux. Sometimes it refers to a physical input device such as a serial port, and sometimes it refers to a virtual TTY where it allows users to interact with the system (reference). TTY is a subsystem in Linux and Unix that makes process management, line editing, and session management possible at the kernel level through TTY drivers. In terms of programming, you need to dive in deep. But, considering the scope of this article, this could be an easy definition to digest. If you are curious, you can explore an old resource (TTY Demystified) that tries to clear up TTY in Linux and Unix systems with all the technical details you need. In fact, whenever you launch a terminal emulator or use any kind of shell in your system, it interacts with virtual TTYs that are known as pseudo-TTYs or PTY. You can just type in TTY in your terminal emulator to find the associated PTY.
How to Access TTY in Linux?
It is easy to access TTY in Linux. In fact, when I did not have a clue what it was, I accidentally accessed it and panicked about what to do (how to get out from it). You can get the TTY screen by using the following keyboard shortcuts on most distributions: CTRL + ALT + F1 – Lockscreen
CTRL + ALT + F2 – Desktop Environment
CTRL + ALT + F3 – TTY3
CTRL + ALT + F4 – TTY4
CTRL + ALT + F5 – TT5
CTRL + ALT + F6 – TTY6 You can access up to six TTYs in total. However, the first two shortcuts point to the distribution’s lock screen and the desktop environment. So, you get a command-line interface with the rest of the shortcuts.
When Would You Use TTY in Linux?
TTY is not just a technical treasure. It is useful even for users like me who aren’t developers. It should come in handy in case the graphical desktop environment freezes. In some cases, reinstalling the desktop environment from the TTY helps resolve the program. Or, you can also choose to carry out tasks in TTY like updating the Linux system and similar, where you do not want visual issues to interrupt your process. Worst-case scenario, you can go to the TTY and reboot the computer if your graphical user interface is unresponsive. Some users also prefer to perform large file transfers with the help of TTY (I am not one of them).
TTY as a Command in Linux
When you type in TTY in your terminal emulator, it will print the file name of the terminal connected to the standard input, as described by the man page. In other words, to know the TTY number you are connected to, just type in TTY. And, if there are multiple users connected to the Linux machine remotely, you can use the who command to check what other users are connected to.