Skip to main content

TTY in linux and how to use it



Ok, how about we start with what is TTY.It stands for “teletypewriter.”


What can tty tell us.
In Linux, there is a pseudo-teletype multiplexor which handles the connections from all of the terminal window pseudo-teletypes (PTS). The multiplexor is the master, and the PTS are the "slaves". The multiplexor is addressed by the kernel through the device file located at /dev/ptmx.



The tty command will print the name of the device file that your pseudo-teletype slave is using to interface to the master. And that, effectively, is the number of your terminal window.

The output shows that we are connected to to the device file at /dev/pts/4.

Our terminal window, which is a software emulation of a teletype (TTY), is interfaced to the pseudo-teletype multiplexor as a pseudo-teletype (PTS). And it happens to be number four.For the number at the end shows that.

The Silent Option.

The -s (silent) option causes tty to generate no output.

This is how it will look on your terminal


It does is produce an exit value, however:

  • 0: if standard input is coming from a TTY device, emulated or physical.
  • 1: if standard input is not coming from a TTY device.
  • 2: Syntax error, incorrect command line parameters were used.
  • 3: A write error has occurred.

The who Command

Other commands can reveal your TTY number. The who command will list information for all logged in users, including yourself.


User root is shown as connected to “:1”.

This represents the screen and keyboard physically connected to the computer. Even though the screen and keyboard are hardware devices, they are still connected to the multiplexor through a device file. tty reveals that it is /dev/pts/4.


Accessing a TTY

You can access a full-screen TTY session by holding down the Ctrl+Alt keys, and pressing one of the function keys.

Ctrl+Alt+F4 will bring up the login prompt of tty4.

If you log in and issue the tty command, you’ll see you are connected to /dev/tty4.

This isn’t a pseudo-teletype (emulated in software); it is a virtual teletype (emulated in hardware). It is using the screen and keyboard connected to your computer, to emulate a virtual teletype like the DEC VT100 used to do.

You can use function keys Ctrl+Alt with function keys F3 to F6 and have four TTY sessions open if you choose. For example, you could be logged into tty3 and press Ctrl+Alt+F6 to go to tty6.

To get back to your graphical desktop environment(GUI), press Ctrl+Alt+F2.

At one time, Ctrl+Alt+F1 through to Ctrl+Alt+F6 would open up the full-screen TTY consoles, and Ctrl+Alt+F7 would return you to your graphical desktop environment. If you are running an older Linux distribution, this might be how your system behaves.

This was tested on the latest release of Ubuntu, Kali Linux, Manjaro, Fedora, Arch and they all behaved like this:

  1. Ctrl+Alt+F1: Returns you to the graphical desktop environment log in screen.
  2. Ctrl+Alt+F2: Returns you to the graphical desktop environment.
  3. Ctrl+Alt+F3: Opens TTY 3.
  4. Ctrl+Alt+F4: Opens TTY 4.
  5. Ctrl+Alt+F5: Opens TTY 5.
  6. Ctrl+Alt+F6: Opens TTY 6.
Having access to these full-screen consoles allows people using command-line only installations of Linux—and many Linux servers are configured this way— to have multiple consoles available.


Linux users having bieng able too access these full-screen consoles using command-line only, they are able to configure linux servers and having multiple consoles available.



The tty command gets its name from a device from the late 1800s, appeared in Unix in 1971, and is part of Linux and Unix-like operating systems to this day.

Comments

Post a Comment

Popular posts from this blog

Improve your Efficiency in Linux using "Alias" command

Have you ever tried to make a custom  command in Linux that can do a specific function. Fear not today we are going to look at how we can do that and increase our efficiency in Linux using the "alias" command What is an alias in Linux So,normally we have to use Linux commands frequently and typing the same commands over and over again can reduce efficiency .And that is one of the reasons we use the aliases List currently defined Aliases in Linux You can see a list of defined aliases on your profile  by simply executing the alias command and it will do the magic. here you can see the default aliases for the Linux systems. How to create Aliases in Linux. Create temporary Aliases:           alias alias_name='command' here is an actual example          alias la='ls -alh' What you need to do is type the word alias then use the name you wish to use to execute a command followed by "=" sign and quote the command you wish to...

What are browser cookies and how they work

INTRODUCTION. Most internet users are familiar with the term Cookie because we see it pop up in most websites but do we know the purpose it serves. Let us start with what it is ,   a cookie (  also known as browser cookie , internet cookie , web cookie or HTTP cookie ) is small piece of data that websites store on your disk in the form of a text file.Cookies allow websites to store specific information helpful to remember each visitor uniquely. What do browser cookies do. The purpose of the computer cookie is to help the website track of your visits and activity and is not a bad thing.A good example are the online retailers to keep track of the items in user's shopping cart as they explore the site, without the cookies the shopping cart would reset to zero with every click. A website also uses the cookies to store information about you recent visits or record you login information which i do not really recommend from a security perspective Types of browser cookies. Session co...

What is session hijacking and how to prevent it.

What is session hijacking Session hijacking is a type of web attack where an attacker takes advantage of an active session.The attack relies on the knowledge of your session cookie, so it is also called cookie hijacking or cookie side-jacking. Although any computer session could be hijacked, session hijacking most commonly applies to browser sessions and web applications. In most cases when we log in web applications, the server always sets a temporary session cookie in your browser to remember you are currently logged in and authenticated. For an attacker to perform session hijacking, he or she needs to know your session id.This can be done by stealing the session cookie or by persuading the user to click on an malicious link.In both cases the attacker can take over the session by using the same session id on his own browser session.And with that  the server has been fooled into treating the attackers session to be the original valid connection. What are the main methods of Sess...