1

The X window system in a desktop Linux (where just one physical monitor is used) usually uses display 0, screen 0. The output of who in Ubuntu 14.04 is

user1   :0           2016-06-15 14:25 (:0)

where :0 is the abbreviation for :0.0 (:display.screen). Here I logged in only from the GUI.

Then I opened a terminal emulator; I ran screen and I created two different windows (each of them simply contained bash). The resulting output of who was:

user1   :0           2016-06-15 14:25 (:0)
user1   pts/1        2016-06-15 14:26 (:0)
user1   pts/11       2016-06-15 16:31 (:0:S.0)
user1   pts/11       2016-06-15 16:31 (:0:S.1)

Why is this syntax used? It seems to be :display:display.screen. Does screen emulate another display inside the physical display?

3

You're referring to the text at the end of the line. That is written by screen to indicate which pseudo-terminal connection it is using, as well as which window-number screen has assigned to it. Comments in the code indicate what it does:

/* 
 * Construct a utmp entry for window wi. 
 * the hostname field reflects what we know about the user (display) 
 * location. If d_loginhost is not set, then he is local and we write 
 * down the name of his terminal line; else he is remote and we keep 
 * the hostname here. The letter S and the window id will be appended. 
 * A saved utmp entry in wi->w_savut serves as a template, usually. 
 */

and later

      /* 
       * we want to set our ut_host field to something like 
       * ":ttyhf:s.0" or 
       * "faui45:s.0" or 
       * "132.199.81.4:s.0" (even this may hurt..), but not 
       * "faui45.informati"......:s.0 
       * HPUX uses host:0.0, so chop at "." and ":" (Eric Backus) 
       */

concluding with the actual code which you might recognize:

    sprintf(host + strlen(host), ":S.%d", win->w_number);

    strncpy(u.ut_host, host, sizeof(u.ut_host));

which stores the string in the ut_host member of the utmp/utmpx structure.

Further reading:

  • Thank you so much. So, basically it is screen which writes and decides this syntax for the utmp entries, not the X server. Is it right? – BowPark Jun 20 '16 at 9:59
  • 1
    yes, that is correct. – Thomas Dickey Jun 20 '16 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.