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

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.


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

  • pts = "pseudo terminal slave": login device when connecting through the network or a console (e.g. ssh).

  • tty = "teletype": serial or console connections (text mode)

  • :0 = "local:display #0": X11 server, used for graphical login (e.g. gdm)


Do as booting to graphical.target way.

ps -el |grep -v ?
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0   683     1  0  80   0 -  4867 -      tty1     00:00:00 agetty
4 S     0   901   686  1  80   0 - 63109 -      tty7     00:00:10 Xorg
0 S  1000  2390  2388  0  80   0 -  7368 -      pts/0    00:00:00 bash
0 R  1000  2465  2390  0  80   0 -  3935 -      pts/0    00:00:00 ps
0 S  1000  2466  2390  0  80   0 -  4446 -      pts/0    00:00:00 grep

1.tty7 and tty1-tty6
it is a kind of virtual terminal such as tty1-tty6.
proof1:in the output info ps -el |grep -v ?,in the third line----tty7.
Proof2:man chvt
chvt - change foreground virtual terminal. You can switch between tty1-tty7 with sudo chvt n (n's range from 1 until 7.) tty7,belong to tty family,is a knind of vertual terminal ,and is in a gui mode,differing from tty1-tty6 which are in text mode.

2.pts
pts means pesudo tty slave which is used with the pseudo terminal master. To get the pts structure of telnet session from web page

Description of a telnet session

in Figure 4: Description of a telnet session.

enter image description here

When bash (ps,grep) run on Xorg in my example,the pts structure is smoething like the below graph(enlightened by R.Koula,author of Description of a telnet session)

enter image description here

The controlling terminal for bash(ps,grep) is pts/0.

3.:0

w
 09:36:09 up 24 min,  1 user,  load average: 0.11, 0.25, 0.29
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
debian8  :0       :0               09:12   ?xdm?   5:13   0.13s /usr/bin/lxsess

ps -lC lxsession
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S  1000  1585  1574  0  80   0 - 91715 -      ?        00:00:00 lxsession

From ps -lC lxsession it is obvious that lxsession is a daemon which has no controlling terminal,so w can't yield info such as ttynumber(from 1 till 7) or pts/number. w yield :0 ,meaning local:display #0 ,to describe the fact on the hardware side,Xorg runing at local:display #0.

Tags:

Tty

Pty

Who