TTY vs PTS – Difference Between PTS, TTY, and :0

ptyttywho

Please help me to distinguish pts from gui mode generated from tty.

booting to multi-user.target

I did this:

  1. sudo systemctl set-default multi-user.target
  2. reboot
  3. login with regular user debian8
  4. ctrlaltf2 and login with regular user debian8 too.
  5. run startx to switch into gui
  6. run tty and who, which said:
    $ tty
    /dev/pts/0
    $ who
    debian8  tty1         2017-01-09 20:22
    debian8  tty2         2017-01-09 20:23

Why is the output of who not this instead?

who
debian8  tty1         2017-01-09 20:22
debian8  :0         2017-01-09 20:23

I have run startx to enter into gui mode, and tty said pts/0. So why does who output tty2 not :0?

My confusion after the explanation by Kusalananda

enter image description here

When tty is run, we get /dev/pts/0. But look at the above. In the TTY column of the output of w the row for startx says tty2. Why6 is not :0?

What is the difference between /dev/pts/0 and tty ?

The tty2 output when I start X with xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 vt2 -auth /tmp/serverauth.451rqHm1NC — is it a pts or not? It outputs

$ tty
/dev/pts/0

This says that the tty here is a pts, I think.

booting to graphical.target

I did this:

  1. sudo systemctl set-default graphical.target
  2. reboot
  3. login with regular user debian8
  4. run tty, yielding
    $ tty
    /dev/pts/0
  5. ctrlaltf2 and login with regular user debian8 too.
  6. run tty, yielding
    $ tty
    /dev/pts/1
  7. run w

enter image description here

There are two guis. They can be switched between with ctrlaltf1 and ctrlaltf2.

Running the command tty, both terminals say /dev/pts/0 or /dev/pts/1. But look at the output of w above. Why does the terminal column for /usr/bin/lxsession -s LXDE -e LXDE say :0? And why does the terminal column for xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :1 vt2 -auth /tmp/serverauth.k7JPJJEAHJ say tty2?

What is the difference between pts and tty and :0?

Best Answer

The who utility by default displays information relating to the login. If you logged in an tty2, then who will say so.

Use the w command to show information about the users currently logged into the machine and on what terminal they are doing what on.

Update: "What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?" describes some differences between a TTY and a PTY. :0 is the particular host display that you are connected to.