Login user status
freebsd at edvax.de
Fri Dec 18 03:16:03 UTC 2020
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".
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions