What is tty7/tty2 in the commandline?

Recently I have been playing around in terminal and typed the who command. As I see my username and date, I don’t know what tty7 (tty2 on Ubuntu 17.10 and newer) or what this pts/0 is, can somebody explain this to me?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

The name of TTY actually comes from the old days of computers: then computers even had teletypewriters as terminal, so you could see the output of programs printed (tty = TeleTYpe/TeleTYpewrite).

TTY usually refers for "physical" terminals, like more attached terminals (even like a teletypewriter) to a single computer, or in our days: more separated text consoles, you can switch between them Ctrl + Alt + F1-F7 (or more, if you have configured more; F3-F6 on Ubuntu 17.10 and newer).

In case of Ubuntu, tty7 is usually used by Xorg/Wayland display server, do provide your graphical environment (to be more exact, it provides a "windowing system" only, and things like the gnome – as a desktop environment solution – runs "top of it").

By contrast, "pts" is (one half of) a notion of "pseudo terminal" which implements terminal functionality without the context of a "real" physical terminal, for example if you open gnome-terminal, for the shell (which is usually the bash on Ubuntu systems) to be able to run, it needs terminal capabilities.

This is also the case if you use "ssh" to log in a remote machine, so in nutshell: whenever something needs terminal/tty like functionality without having a ‘real’ tty.

Solution 2

I think usually it’s the display server (X server).

Press Ctrl+Alt+F7 (F3 on Ubuntu 17.10 and newer) and see if it takes you to your graphical login session (or keeps you there).

You can also open a shell and run tty. It will tell you the name of your current terminal.

Solution 3

tty7 is the physical terminal from which you logged in. In many cases, tty7 is where your window manager runs and from which you login.

As can be seen from the listing below, I logged in at 9:33 on May 24 from tty7 (via Gnome window manager login dialog) and then opened 4 pseudo terminals.

[[email protected] ~]$ last | tac | egrep "May\s*24"

sgoda    tty7         :0               Wed May 24 09:33   still logged in   
sgoda    pts/0        :0               Wed May 24 09:33   still logged in   
sgoda    pts/2        :0               Wed May 24 09:36   still logged in   
sgoda    pts/4        :0               Wed May 24 09:40   still logged in   
sgoda    pts/5        :0               Wed May 24 09:42   still logged in 

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply