14

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?

4
  • Well, you didn't login on :0, right? Commented Jan 9, 2017 at 13:15
  • yes not directly login on :0. . Commented Jan 9, 2017 at 13:21
  • reboot into text mode ,then switch to tty2 ,and input to startx ,to enter gui mode Commented Jan 9, 2017 at 13:21
  • 4
    Can you rewrite the question, using sentences? Commented Jan 9, 2017 at 14:16

3 Answers 3

12

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)

9

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.

0
5

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.