2

My observation:

  1. If I open a new terminal (gnome/lx):

    • New /dev/pts/X is used
    • who does not lists these
    • First character of echo $0 is not -, so its not a login-shell.
  2. If I ssh into the same machine with the same user

    • New /dev/pts/X is used
    • who lists these
    • First character of echo $0 is -, so its a login-shell.
  3. If I open a new tty (ctrl-alt-Fxx)

    • New /dev/ttyXX is used
    • who lists these
    • First character of echo $0 is -, so its a login-shell.
  4. If I run su -

    • Same /dev/pts/X is used ( where su - was issued )
    • who does not list these
    • First character of echo $0 is -, so its a login-shell.

Conclusion:

  1. Creating a new pty does not automatically create an entry in utmp (?)

Question:

  1. If who displays the list of currently logged in users, then it should display entries for each login-shell (?). But it does not display entries of root user logged in from su -, why ?

EDIT: Another thing which I can conclude at this point is: "It has to be a new pty/tty and a login shell, then only a new entry is created in utmp"

  • a ssh login actually also not always creates a who entry. I suspect the who entry is somewhat created by the first interactive shell of each separate login; never investigated the problem. good question. – Rui F Ribeiro Aug 25 '17 at 7:22
  • @RuiFRibeiro No it doesnt, you are talking about Observation #1 ( not listed under who ). From here if I do ssh (observation #2), new entries are listed in who – P Pang Aug 25 '17 at 7:25
2

First, who does not care about login shells, or anything such. It merely dumps utmp entries. You can have an entry for non-login terminals; for graphical sessions; for FTP connections (with a completely made-up tty "line" name); for just about anything.

Second, utmp entries are created manually – you only get an entry if the program which processes your login calls pututline(…). For example, sshd always does this, terminal emulators often do this (but not always), and su never does.

(Remember that su does not allocate a new pty, so it can't add an utmp entry either – otherwise you'd end up with multiple entries for the same tty, which can confuse a few programs.)

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.