LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to get all login users? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-all-login-users-4175573724/)

sluge 03-02-2016 06:31 AM

How to get all login users?
 
Hello,

I need to know if user test in login in.

I created two ssh connections, and in the second one I executed:

Code:

# su - test
$

On the first one I executed:
Code:

# who -u
root    tty1        2016-03-02 12:59 02:13        2124
root    pts/0        2016-03-02 13:16  .          8250 (192.168.1.11)
root    pts/1        2016-03-02 15:23 00:03        5083 (192.168.11.12)

So, test isn't detected. Is any way to detect if test user login?

Emerson 03-02-2016 06:39 AM

su - test is not test user login, it is root switching to test, but still root.

pan64 03-02-2016 06:50 AM

based on man su:
Code:

NAME
      su - change user ID or become superuser

SYNOPSIS
      su [options] [username]

      -, -l, --login
          Provide an environment similar to what the user would expect had the user logged in directly.

based on man who:
Code:

NAME
      who - show who is logged on

      -u, --users
              list users logged in

conclusion:
su - test will provide an environment, but actually will not log user in. When you execute tty you will see the current terminal and who will show you who was logged in on that terminal - in your case that was root.

BW-userx 03-02-2016 07:32 AM

six ways to find out who is logged in on system

JoseKreif 03-02-2016 07:44 AM

1 Attachment(s)
I've always used finger.

After looking at the link BW-userx suggested, I can see it's listed there if you want to read about it


All times are GMT -5. The time now is 12:10 PM.