LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Number of current sessions for user (http://www.linuxquestions.org/questions/linux-newbie-8/number-of-current-sessions-for-user-725404/)

neel_learning_linux 05-12-2009 06:44 AM

Number of current sessions for user
 
Hi!

when I run "su <username>" as root, a new session is created. If wanted to know how many such sessions currently exists for a particular user (active or inactive), how do I find that out?

Thanks in advance,
-Neel.

dandart 05-12-2009 08:30 AM

use "who".

neel_learning_linux 05-13-2009 05:54 AM

I found that "who" gives the users that have logged in to terminal. Even if "su <username>" succeeds in changing the owner of the session/effective uid, that does not affect output of "who".

To rephrase the original question, what I want is the way to find out how many sessions exist with effective uid of given user.

Do let me know if I am missing something.

Thanks again,
-Neel.

onebuck 05-13-2009 07:39 AM

Hi,

You can use 'users' from the cli which will give you the user name then perform on that.

Quote:

excerpt from 'man users';

users - print the user names of users currently logged in to the cur-
rent host

SYNOPSIS
users [OPTION]... [ FILE ]

DESCRIPTION
Output who is currently logged in according to FILE. If FILE is not
specified, use /var/run/utmp. /var/log/wtmp as FILE is common.

--help display this help and exit

--version
output version information and exit

malekmustaq 05-13-2009 08:40 AM

neel_learning_linux:

this post is already two days and nobody is able to "decipher or decode" your cryptic question

please ask your question clearly and you shall be attended to properly

Tinkster 05-13-2009 03:14 PM

Quote:

Originally Posted by neel_learning_linux (Post 3539234)
I found that "who" gives the users that have logged in to terminal. Even if "su <username>" succeeds in changing the owner of the session/effective uid, that does not affect output of "who".

To rephrase the original question, what I want is the way to find out how many sessions exist with effective uid of given user.

Do let me know if I am missing something.

Thanks again,
-Neel.

I hope I understand corectly what you mean by a "session"
in this context

Code:

ps -eo euid,command|grep bash|grep -v grep | sort|uniq -c

Cheers,
Tink


All times are GMT -5. The time now is 07:31 PM.