Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Dec 2020 04:15:48 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Jos Chrispijn <bsduser@cloudzeeland.nl>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Login user status
Message-ID:  <20201218041548.3b14af1d.freebsd@edvax.de>
In-Reply-To: <6a3ead3e-fec6-7a58-7ad2-c9af0fbf0de9@cloudzeeland.nl>
References:  <6a3ead3e-fec6-7a58-7ad2-c9af0fbf0de9@cloudzeeland.nl>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Fri, 18 Dec 2020 00:03:37 +0100, Jos Chrispijn wrote:
> When I login to my BSD server, I do that with a regular user account and 
> swith then to my admin account.
> What I don't understand is that if I use the 'who' query from the 
> prompt, only the regular username is shown where it also should show the 
> root user being logged in.
> Can you tell me what causes this behavior?

This is the normal and expected behaviour. The context "logged in"
is true for those users who use the login program to log in, i. e.,
any regular interactive users. When you "switch to" an admin user,
typically root, by using "su -" (or "su -m"), such a login is not
performed. Instead, the execution environment is altered and only
a new shell instance is started.

>From "man su":

     By default, the environment is unmodified with the exception of USER,
     HOME, and SHELL.  HOME and SHELL are set to the target login's default
     values.  USER is set to the target login, unless the target login has a
     user ID of 0, in which case it is unmodified.  The invoked shell is the
     one belonging to the target login.  This is the traditional behavior of
     su.  Resource limits and session priority applicable to the original
     user's login class (see login.conf(5)) are also normally retained unless
     the target login has a user ID of 0.

As you can see, nothing actually creates a new login entry in a way
that the "who" program could pick that up. If you use a program
like "htop" and press PF5 (process tree), you can see that the
"root session" is just a subprocess of the "user (login) session".
Programs like "w" behave the same way and do not display the root
user as being logged in - because it isn't.

You can find more information in "man who" and "man login".



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20201218041548.3b14af1d.freebsd>