dum question about users, terminals and so on

Hi there,

I have a maybe stupid question regarding users and terminals. Just to understand the system a bit better.

I know that when you open a terminal (console), there is another user logged into the system, even when you do just normal stuff, without roor privilegues. When you exit this console, the user is logged out again.

But on my systems (Desktop and Laptop) there are always two users logged in, even when it is just me (the normal user) and no terminal, no console is opened. When I open a console, then there are three users…

when I look the users up in a terminal, it shows me twice:

steffen  pts/0                         Sat Apr 30 11:09   still logged in
steffen  pts/1                         Sat Apr 30 08:46   still logged in   
steffen  console      :0               Sat Apr 30 08:46   still logged in

so the one with “pts/0” is the one from the terminal, which is opened right now.

As far as I recall, in Ubuntu (in my earlier Linux life) I always had one user, and when I opened a terminal, I had 2 users…

from what is the 2nd “normal user” in openSUSE?

so first of all, this is to understand the system better, but it also to see: is everything alright with my system?

thanks for some answers on this!

regards
Steffen

It is the same user, but there are more sessions. I first thought you were worrying about another user loged in. Happily this is not the case.

IIRC this question was asked before, but I can not clearly remember all the details.
You did not show the statement with which you got the above output. That would have helped other people to do likewise to check if they have the same without searching in the deepest of their memory.

but why are there more sessions? Is it something with all the runlevel stuff? So that when I boot up the system, I have the system running, which runs without GUI and the GUI on top of it with another user (myself again)?

the command for getting the information in the terminal was

last

which shows all of the last logins by every user on the machine.

I have the same on 11.2:

henk@boven:~> last | grep still
henk     pts/1                         Sat Apr 30 21:37   still logged in
henk     pts/0                         Sat Apr 30 10:15   still logged in
henk     :0           console          Sat Apr 30 10:14   still logged in
henk@boven:~>

Thus your system is not abnormal.

When you boot the system, no user is loged in. Users log only in after the system is booted fully. That can be done automaticaly, some users prefer that a GUI session is started for a specific user without further user identification. But that automatic login is configured to be there and can of course only work for one of the configured users. The result is not different from that user loging in with username/password in KDM/GDM.

I can not find any process in the process list that is connected to pts/0.

I guess it is some “trick” to have the internal administration working. Like the whole pts/pty device is a trick to let virtual terminals function (originaly there were of course real tty devices).

This certainly is not the whole answer. Let us hope someone else will tune in.

On 2011-04-30 20:36, steffen13 wrote:
> when I look the users up in a terminal, it shows me twice:

And my 27 times. Normal.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On 2011-04-30 21:36, steffen13 wrote:
> which shows all of the last logins by every user on the machine.

Not really. My user has 301 entries there.
They are historic entries.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Here’s more detail than you ever wanted to know :frowning:

Normally, when somebody logs in, a record is written to “/var/run/utmp”.

When you list who is logged in, what you are listing is based on that “utmp” file.

When you login to the display manager (a GUI session), then a record is written to “utmp” showing the terminal as “:0”, which really isn’t a terminal (it’s the display). When you open a command line terminal, normally a record is written to “utmp”. It is actually possible to open a command prompt with the command:
xterm -ut
and that won’t write a record to “utmp”.

Your question was about the record for terminal “pts/1”. If I do:
ps -ft pts/1
it doesn’t show anything connected to that terminal. If, however, I use the command:
lsof /dev/pts/1
it does show a connected process, which shows in the process listing as “kdeinit4: kded4 [kdeinit]”

I suspect (but haven’t tested), that if somebody tried to open a talk session to me on pts/1, that would be trapped by kded4 and a popup would display indicating that there is a talk request. Hmm, kded4 seems to be a KDE daemon. Perhaps if I used gnome or XFCE, I would not see that utmp entry.

When you boot the system, no user is loged in. Users log only in after the system is booted fully. That can be done automaticaly, some users prefer that a GUI session is started for a specific user without further user identification. But that automatic login is configured to be there and can of course only work for one of the configured users. The result is not different from that user loging in with username/password in KDM/GDM.

Autologin has nothing to do with this ?

I can not find any process in the process list that is connected to pts/0.

I guess it is some “trick” to have the internal administration working. Like the whole pts/pty device is a trick to let virtual terminals function (originaly there were of course real tty devices).

The pts/* entries are indeed virtual terminals (‘psuedoterminals’). For every login console you open you get a new tty or pts/* opened for your user. You can get ‘real’ tty’s on the virtual terminals (vt) 1-6 (Ctrl-Alt-F1 to F6). If a program (e.g., a DE like KDE) wants to open a new terminal its opens a pts.

The ‘who’ command tells you who is currently logged in at which terminals. ‘last’ is basically just a history of ‘who’.
If you want to know what processes have opened these virtual terminals, try using lsof (the pts’s and tty’s exist as actual files in /dev):

For example on my system, with one console open (yakuake) and also logged in on VT1 (Ctrl-Alt-F1):
Code:

> who
tejas tty1 2011-04-30 21:50
tejas :0 2011-04-30 09:38 (console)
tejas pts/0 2011-04-30 09:38
tejas pts/1 2011-04-30 09:38

> lsof | grep /dev/pts/0
kded4 3995 tejas 25u CHR 136,0 0t0 3 /dev/pts/0
kded4 3995 4000 tejas 25u CHR 136,0 0t0 3 /dev/pts/0
kded4 3995 4035 tejas 25u CHR 136,0 0t0 3 /dev/pts/0
kded4 3995 4047 tejas 25u CHR 136,0 0t0 3 /dev/pts/0

> lsof | grep /dev/pts/1
yakuake 4175 tejas 11u CHR 136,1 0t0 4 /dev/pts/1
yakuake 4175 4178 tejas 11u CHR 136,1 0t0 4 /dev/pts/1
bash 4179 tejas 0u CHR 136,1 0t0 4 /dev/pts/1
bash 4179 tejas 1u CHR 136,1 0t0 4 /dev/pts/1
bash 4179 tejas 2u CHR 136,1 0t0 4 /dev/pts/1
bash 4179 tejas 255u CHR 136,1 0t0 4 /dev/pts/1
lsof 23171 tejas 0u CHR 136,1 0t0 4 /dev/pts/1
lsof 23171 tejas 2u CHR 136,1 0t0 4 /dev/pts/1
grep 23172 tejas 1u CHR 136,1 0t0 4 /dev/pts/1
grep 23172 tejas 2u CHR 136,1 0t0 4 /dev/pts/1

In fact in the last example, you can see that the terminal I am looking at is the one where I typed the lsof command!

The ‘w’ command gives a quicker summary of this:
Code:

> w
21:50:53 up 12:25, 4 users, load average: 0.13, 0.20, 0.40
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
tejas tty1 21:50 48.00s 0.60s 0.60s -bash
tejas :0 09:38 ?xdm? 1:42m 0.10s /bin/sh /usr/bin/startkde
tejas pts/0 09:38 12:12m 0.00s 2:09 kdeinit4: kded4 [kdeinit]
tejas pts/1 09:38 0.00s 1.34s 0.00s w

again, the last entry is the terminal where I actually ran the ‘w’ command, the first one is me logged in on VT1, and the next two are KDE.

So basically the summary is, unix/linux is truly a multiuser system, and so each time you open a new console (even within a DE), you are actually logging in again. This is all the multiple user entries mean.

You’re running in a multi-user environment.
IMHO, some communication operations for security reasons run in separate sessions to insulate those sessions from other sessions, ie, closing terminals doesn’t close other terminals.
FWIW, you’d see 2 or 3 or more users with other users on your system running terminals, console (GUI), apps, etc.

I just tested that with XFCE and with ICEwm. In both cases the list of logged in users contained only two entries. One was for “:0” (the desktop session), and the other was for the xterm that I had open to run the “who” command. So the additional entry appears to be a KDE special.

I didn’t test gnome. The comment about ubuntu in the opening post suggests that gnome does have that extra entry either.

thanks guys, for all the explainations!

after doing the command w, I get:

steffen@linux-rq64:~> w
 16:24:19 up  7:38,  3 users,  load average: 0,00, 0,01, 0,05
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
steffen  :0        08:46   ?xdm?  58:08   0.12s /bin/sh /usr/bin/startkde
steffen  pts/1     08:46    7:38m  0.00s  7.69s kdeinit4: kded4 [kdeinit]                      
steffen  pts/0     16:22    0.00s  0.01s  0.00s w

so it also tells me that there is one user running since today in the morning with the reason kdeinit4 and the other one because of /usr/bin/startkde. So it has something to do with KDE then.

I don´t remember if this was also the same as I have used Kubuntu some time ago. But for now I am starting to be convinced that it is something KDE-special :smiley:

No. Autologin is a configuration of the Display Manager (xdm, kdm, gdm whatever you use). You can see it as if the typing of username/password is done for you. All the rest is the same as if you typed them yourself.