Skip to main content
added how to determine how user is logged in
Source Link
DougC
  • 146
  • 4

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

If you just want the user names, you can use the "users" command which will just print the user names:

doug@LinuxMint ~ $ users
doug test

As for how they logged in, you could check for environmental variables such as SSH_CONNECTION, SSH_CLIENT, REMOTEHOST, DISPLAY, and SESSIONNAME to see.

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

If you just want the user names, you can use the "users" command which will just print the user names:

doug@LinuxMint ~ $ users
doug test

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

If you just want the user names, you can use the "users" command which will just print the user names:

doug@LinuxMint ~ $ users
doug test

As for how they logged in, you could check for environmental variables such as SSH_CONNECTION, SSH_CLIENT, REMOTEHOST, DISPLAY, and SESSIONNAME to see.

removed section not useful to question
Source Link
DougC
  • 146
  • 4

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

If you just want the user names, you can use the "users" command which will just print the user names:

doug@LinuxMint ~ $ users
doug test

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.

If you just want the user names, you can use the "users" command which will just print the user names:

doug@LinuxMint ~ $ users
doug test
Source Link
DougC
  • 146
  • 4

The "w" (or who) command will show the currently logged in users. For example:

doug@LinuxMint ~ $ w
 12:23:36 up 41 min, 2 users, load average: 0.69, 0.24, 0.15
USER     TTY     FROM     LOGIN@     IDLE    JCPU     PCPU WHAT
doug     tty7    :0       11:42     40:54    7.39s    0.07s cinnamon-session
test     tty8    :20      12:23     40:54    0.97s    0.04s cinnamon-session

In this example user "test" was logged in, and I used switch user to log in as "doug" and run the "w" command.