[SOLVED] Finding out connected users in shell

Hi there!
This may be a simple question at first glance: who is connected and how many sessions per user are opened?  I thought a 'who' or 'w' would do it.
Sadly, it will only work with TTY sessions. Any session started from a login manager for X will not be taken into account by any of the aforementioned commands.
'loginctl list-... ' does the trick for systemd-based systems. But I'm looking for a more portable solution (BSD, other GNU, etc.).
Any thoughts?
Last edited by Ambrevar (2014-01-11 08:51:00)

Thanks, Trilby, this seems to be a good lead!
I've been playing with 'ps' a little to see what I could get. First I think the following command is equivalent and more portable:
$ ps -ax -o user='' -o tty='' | sort -u
'-e' is GNU-specific, and --no-header can be avoided by setting all header entries to the null string.
This will display all 'users', even 'root', 'polkitd', 'dbus', etc. Every X terminal will add another superfluous entry, but we can get rid of it easily:
$ ps -ax -o user='' -o tty='' | grep -v ' pts/' | sort -u
To display a list of all users with the number of started sessions:
$ ps -ax -o user='' -o tty=''| sort -u | awk '$0 !~ / pts\// {x[$1]++} END{for(i in x) print i, x[i]}'
doe 2
polkitd 1
dbus 1
root 3
To display the number of started session for the specified user:
$ ps -o user='' -o tty='' -u $USER | sort -u | grep -cv ' pts/'
Do not use '-U $USER', since it will display one root entry per X session (X euid is $USER but X ruid is root).
I've not tested the above commands on BSD systems, but according to the 'ps' man page from FreeBSD, this should work well. But it may fail if the TTY are not reported the same way. It also relies on the pts names.
Don't know if anyone can come up with a better suggestion, but for now I'm quite satisfied with the result, so I'll mark it as a 'solved'. Thanks again!
Last edited by Ambrevar (2014-01-11 08:53:36)

Similar Messages

  • How to find out the user who has created  a new field in the custom table.

    How to find out the user details who has created  a new field in the custom table.
    Thanks,
    Joan

    Hi Jesudasan ,
    You can know the user details with version management.Please find the
    below procedure to know.
    Go to table->Utilities tab->version->Version management->Compare the previous one .
    Hope this solves the issue,Let me know if you have any issues.
    Thanks,
    Rajani

  • How to find out which user has the permission to execute startsap ?

    Hi All
    How do I find out which user has the permission to execute the startsap and stopsap? Do I control the permission on those script using windows standard authorization? For example: only allow certain user have the read and write permission?
    Thank you.!
    Vincent Lo

    Well to me this is really weird question..
    <b>noone un-authorized should have access to OS on your system</b>
    If this is valid you do not need to solve problems who can and who cannot start/stop SAP, because if you want to prevent some users from shutting down the SAP you have really hard job to do - there are many ways how to kill the SAP (for example killing relevant process from task manager, killing of database, messing with services etc.) - yes, this is harmful way of stopping SAP, but we are talking about attack, right? I would contact some Windows specialist to help you disable all the ways how to harm the running SAP. But still after that - there are many files that can be modified/deleted so SAP will crash after restart - you need to protect them too, etc.
    In case you take the first assumption as granted (and you really limit access to this server) you do not need to worry who can stop or start SAP - at the other hand it may be handy to be able to start/stop SAP from other users - for this you can run the stop/start script "under different user".
    But to answer the question - to me this is question just of access control (but really never tried that myself):
    <a href="http://technet2.microsoft.com/WindowsServer/en/library/c6413717-511e-42bd-bd81-82431afe4b2a1033.mspx">Permit or restrict access to a snap-in for a domain</a> (or see other related links down there on this page)
    Please award points for useful answers.
    Thanks

  • How to find out what user locked account

    We had production type schema account locked this morning. I checked profile which this user belongs and it has 3 times for Failed Login Attempts. My question is how to find out what user had 3 unsuccessful login attempts and lock this account.
    Oracle version 8.1.7

    Assuming that [auditing was enabled|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/security.htm#sthref2916], the command
    AUDIT CONNECT WHENEVER NOT SUCCESSFULThat will write audit records when there is an unsuccessful login. Depending on how you've configured auditing, those records will either be written to the SYS.AUD$ table, in which case you can query them through a few different views, or to a file on the operating system that you can grep.
    Justin

  • Can I find out, with user has deleted all cost estimates with CKR1?

    Hi Community,
    ich have a major problem: all our standard material don't have a cost estimate any more, because a unknown user has deleted all current cost estimates. Can I find out, with user has used the CKR1 transaction? And much more importend: how can I solve the problem? Do I need to re-calculate all the material?
    Thanks for any idea and help
    PoD

    Hi,
    you have to make the costing run, marking, releasing again but thats not the whole work.
    If there are PP-orders that have been created based on the old/deleted plan cost estimates, the variance calculation will not work as the plan cost estimate is missing (even if the new one is released in the same period).
    Thus variance calculation is not possible for those orders... You have to settle the whole balance to receiver object by removing the variance key in PP-order. Try first for one particualr order to see if there are some other problems that need to be solved during month-end-closing.
    How to find out who has executed CKR1 (SAPCKR1): Check authorizations for (hopefully) a small number of user who are allowed to use CKR1.
    Use T-Code ST03N, in the left upper window double-click "total" (maybe click a day if you can imagine which (possible) date it was). In lower left section open "user and settlement statistics" and then click "user profile". Now go to each possible user and look for T-Code CKR1.
    This can be time-consuming but its worth a try...
    For the future: restrict CKR1 to a very small number of user (and they should be well trained...). I once had a company (with poor authorization concept) but CKR1 was blocked in SM01 and a ZCKR1 was created and in this Z-transaction USER-name was checked (if SY-USNAM...) so only the use names named in this Z-program were allowed to use ZCKR1. Not the best way but sufficient for them...
    Good luck, Christian

  • To find out which user is schema

    Hi
    All,
    Do you have any idea to find out which user is schema ? (example : any sql query)
    Thanks,
    Vishal

    It's quite unlikely that I would consider an ID that can not connect as being a user. Therefore:
    Schema has objects
    User has CREATE SESSION priv
    Schema & User has objects & CREATE SESSION priv
    Both take use sys.user$.user# so one could view them as different aspects of the same beast. For DBA_USERS the whole key is from sys.user$.user#, whereas for DBA_OBJECTS the sys.user$.user# is a reference for part of the key.
    A schema is simply a collection of objects with a specific namespace. Oracle, for some reason, decided to make the namespace for schemas match the namespace for userids. (I suspect it was to allow us an opportunity to have this kind of discussion.)
    Howard has a discussion that is far superior to the above. I hope we can cajole him to post it.

  • How could I find out which user did release a transport request in the sour

    How could I find out which user did release a transport request in the source system

    Hi Tina,
    Use SE10 t-code and type abaper user name in the user field then check released check box then display and select request number which is released, double click on said request number and click on "object list of request" Then click on "comment: released" than you can find out the released user name at the end of request number along with dated of released.
    I hope you problem will be solved.
    Regards,
    Anil

  • Script to find out that users do not have inheritable permission checked

    Hi all,
    I just check our AD (windows 2003 R2) and some users have "allow inheritable permissions from the parent to propagate to this object and all child objects.  include these with entries expilitly defined here" checked  if I open active directory
    users and computers console and highlight this user and go to properties and select security and click advanced).  some users do not have ""allow inheritable permissions from the parent to propagate to this object and all child objects. " checked.
    Is there a way to script to find out which users do not have "allow inheritable permissions from the parent to propagate to this object and all child objects. .." checked?
    Thank you for your help.

    There are several ways to use ADO in a VBScript program. The alternative below uses an ADO command object, so we can specify a "Page Size". This overcomes the 1000 (or 1500) limit on records returned, as it turns on paging. I have also modified
    the script for comma delimited output. This script should be run at a command prompt so the output can be redirected to a text file. For example:
    cscript //nologo FindUsers.vbs > report.csv
    The modified script follows:
    Option Explicit
    Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
    Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strNTName, strDN
    Dim objUser, objSecurityDescriptor, intNTSecDescCntrl, strInheritable
    Const SE_DACL_PROTECTED = &H1000
    ' Setup ADO objects.
    Set adoCommand = CreateObject("ADODB.Command")
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    Set adoCommand.ActiveConnection = adoConnection
    ' Search entire Active Directory domain.
    Set objRootDSE = GetObject("LDAP://RootDSE")
    strDNSDomain = objRootDSE.Get("defaultNamingContext")
    strBase = "<LDAP://" & strDNSDomain & ">"
    ' Filter on user objects.
    strFilter = "(&(objectCategory=person)(objectClass=user))"
    ' Comma delimited list of attribute values to retrieve.
    strAttributes = "distinguishedName,sAMAccountName"
    ' Construct the LDAP syntax query.
    strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
    adoCommand.CommandText = strQuery
    adoCommand.Properties("Page Size") = 500
    adoCommand.Properties("Timeout") = 30
    adoCommand.Properties("Cache Results") = False
    ' Run the query.
    Set adoRecordset = adoCommand.Execute
    ' Enumerate the resulting recordset.
    ' Write a header line.
    Wscript.Echo """NT Name"",""Distinguished Name"",""Allow inheritable permissions"""
    Do Until adoRecordset.EOF
    ' Retrieve values.
    strNTName = adoRecordset.Fields("sAMAccountName").Value
    strDN = adoRecordset.Fields("distinguishedName").Value
    strDN = Replace(strDN, "/", "\/")
    Set objUser = GetObject("LDAP://" & strDN)
    Set objSecurityDescriptor = objUser.Get("ntSecurityDescriptor")
    intNtSecDescCntrl = objSecurityDescriptor.Control
    If (intNtSecDescCntrl And SE_DACL_PROTECTED) <> 0 Then
    strInheritable = "Disabled"
    Else
    strInheritable = "Enabled"
    End If
    Wscript.Echo """" & strNTName & """,""" & strDN & """," & strInheritable
    ' Move to the next record in the recordset.
    adoRecordset.MoveNext
    Loop
    ' Clean up.
    adoRecordset.Close
    adoConnection.Close
    Richard Mueller
    MVP ADSI

  • How to find out the user iD that previously deleted?

    Hi,
    My client has deleted some user ID in SBO v2004b. HOwever, when the client did that, he forgot to "deselect" the license that granted to the users going to be deleted. What's worse, he forgot the user ID that he deleted.
    It makes the license available decrease. So, how can i find out the user ID that i previously deleted? Or any method to retrieve the correct number of license originally. ?
    Thanks for your advice

    Hi,
    Have a look at the FAQ weblog, Missing licence topic:
    /people/ibai.pea/blog/2006/07/26/sbo-faq
    Regards,
    Ibai Peñ

  • How to find out the user exit is implemented

    Hi All,
    Kindly let me know the process to be followed to find out the User exit is implemented in SAP system.
    I have seen many senriors suggestions for some treads to check if there is any Exit is implemented in the process when the system is behaving differently rather standard.
    Is it the only way with help of ABAP'er we can find out or the functional consultant also can find out through some procedure?
    I tied in google for this doubt, but i could not get the relavant answer.Pleaea execuse me if this already answered.
    Thanks,

    Hi Krishna/TW,
    Thank you for your immediate replies. Sorry i think i have not explained correctly my requirment.
    Let me explain my requirement once again.Let us say Comapny has implemented one Exit in the project, now i want to find out what exactly the Exit was implemented.
    Example: In STO process user is able to increase the  qty in delivery. As per the client requriement system should not allow.
    This is not possible in standard to control even after maintainig  check over delivery field in 0VLP.
    For this comapny has already implemented one enahnceament.
    User Exit : USER EXIT_READ_DOCUMENT
    Program: MV50AFZ1
    like this when any one joined in the project we do not know what are all the Exits are implemented in the SAP system where we are working.
    So if i want to find out if there is any Exit or enhancement implemented, what is the process to find out?
    I hope now  am clear with my requirement.
    Thanks in advance.

  • How to find out the User Details for the particular transaction

    Hi,
    Actually AJAB -Asset Year closing was done by One User.How and Where to find out the User details who executed the Transaction.Kindly tell me the T-code for this.
    Thanks
    Sap Guru

    Hi:
    Please contact you basis administrator.Give him the T.code and date when Year closing was done. He may resolve your problem.
    Please let me know if you need more information,
    Assign points if useful.
    Regards
    MSReddy

  • How to find out the user from the Jobs queue in Report server

    Hello All!
    I have a doubt about finding out the user from the scheduled jobs queue. Say I go ahead and schedule a report on Reports Server how can I find out the user name. When I view the jobs using showjobs I could see that the DBMS_JOBS table has a column under "Job Owner". But it invariantly shows it is "rwuser". So is there a way to find out which user has scheduled which job?
    Regards
    Shobha

    hi,
    The below tables will give only the name .
    USER_ADDRS
    USER_ADDR
    USER_ADDRP
    USR02
    i think you need email address .
    you can use this Tcode : su01d
    and give the user name and excute it
    i hope it will help you.
    Ram
    Edited by: Ram velanati on Jun 30, 2008 6:57 PM

  • How to find out the user-exits?

    hi.
    how to find out the user-exits?
    regards
    eswar.

    Hi,
    *& Report  ZEXITFINDER
    *report  zexitfinder.
    *& Enter the transaction code that you want to search through in order
    *& to find which Standard SAP User Exits exists.
    *& Tables
    tables : tstc, "SAP Transaction Codes
    tadir, "Directory of Repository Objects
    modsapt, "SAP Enhancements - Short Texts
    modact, "Modifications
    trdir, "System table TRDIR
    tfdir, "Function Module
    enlfdir, "Additional Attributes for Function Modules
    tstct. "Transaction Code Texts
    *& Variables
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : v_devclass like tadir-devclass.
    *& Selection Screen Parameters
    selection-screen begin of block a01 with frame title text-001.
    selection-screen skip.
    parameters : p_tcode like tstc-tcode obligatory.
    selection-screen skip.
    selection-screen end of block a01.
    *& Start of main program
    start-of-selection.
    Validate Transaction Code
    select single * from tstc
    where tcode eq p_tcode.
    Find Repository Objects for transaction code
    if sy-subrc eq 0.
    select single * from tadir
    where pgmid = 'R3TR'
    and object = 'PROG'
    and obj_name = tstc-pgmna.
    move : tadir-devclass to v_devclass.
    if sy-subrc ne 0.
    select single * from trdir
    where name = tstc-pgmna.
    if trdir-subc eq 'F'.
    select single * from tfdir
    where pname = tstc-pgmna.
    select single * from enlfdir
    where funcname = tfdir-funcname.
    select single * from tadir
    where pgmid = 'R3TR'
    and object = 'FUGR'
    and obj_name = enlfdir-area.
    move : tadir-devclass to v_devclass.
    endif.
    endif.
    Find SAP Modifactions
    select * from tadir
    into table jtab
    where pgmid = 'R3TR'
    and object = 'SMOD'
    and devclass = v_devclass.
    select single * from tstct
    where sprsl eq sy-langu
    and tcode eq p_tcode.
    format color col_positive intensified off.
    write:/(19) 'Transaction Code - ',
    20(20) p_tcode,
    45(50) tstct-ttext.
    skip.
    if not jtab[] is initial.
    write:/(95) sy-uline.
    format color col_heading intensified on.
    write:/1 sy-vline,
    2 'Exit Name',
    21 sy-vline ,
    22 'Description',
    95 sy-vline.
    write:/(95) sy-uline.
    loop at jtab.
    select single * from modsapt
    where sprsl = sy-langu and
    name = jtab-obj_name.
    format color col_normal intensified off.
    write:/1 sy-vline,
    2 jtab-obj_name hotspot on,
    21 sy-vline ,
    22 modsapt-modtext,
    95 sy-vline.
    endloop.
    write:/(95) sy-uline.
    describe table jtab.
    skip.
    format color col_total intensified on.
    write:/ 'No of Exits:' , sy-tfill.
    else.
    format color col_negative intensified on.
    write:/(95) 'No User Exit exists'.
    endif.
    else.
    format color col_negative intensified on.
    write:/(95) 'Transaction Code Does Not Exist'.
    endif.
    Take the user to SMOD for the Exit that was selected.
    at line-selection.
    get cursor field field1.
    check field1(4) eq 'JTAB'.
    set parameter id 'MON' field sy-lisel+1(10).
    call transaction 'SMOD' and skip first screen.
    Regards

  • How to find out the user list that created by someone?

    Hi all:
    Now I want to develop a program that can find out the user list created by someone.
    such as :
    John create 3 user in SAP ,they are u1,u2,u3.
    Susan create 2 user in SAP , they are s1,s2.
    I input the the parameter such as John , the program can give me the list :u1,u2,u3.
    Could you tell me which table should I use in this program?
    Thanks .
    Elisa.

    Hi Ling,
    As per my understanding, you are looking for listing down the number of Users created by a particular users of the System. Like a System Administrator has created some 30 users. If this is correct, then you can use the table
    USR02 - Logon Data (Kernel-Side Use). This table has 2 fields which are of importance - BNAME - User Name in User Master Record & ANAME - Creator of the User Master Record. You can query the ANAME with the username of the system and you will get the resultant users.
    But I would reccomend to search the Table for a standard class, function module or RFC or BAPI so that you can reuse the same and need not to develop from the scratch.
    Hope this will help.
    Thanks,
    Samantak.

  • How to find out skype user sending me sms?profile....

    Hi All.
    Its of high importance for me to find out the user id of an unknown person sending my wife SMS's through SKYPE. The number showing up from the sender is +442032892491. Upon googling, i found that this number is linked to Skype so if any user sends a sms without setting a number in profile, the default number shows up as above.  Its very important for me to know who has been sending messages to my wife mobile. Can any one please suggest. I also tried sending a message back from my wife mobile to the same number +442032892491 but not sure if its actually reaching there.
    Pls help.
    Regards
    Vishal

    I am definetly starting to think I don't actually have a skype name. Now I tried again since the 24 hour restriction went off. First from Skype webpage ->sign in -> forgotten your skype name? ->there I enter my hotmail address ->send mail ->
    then it moves off from Skype and into account.live.com, where it's no longer asking anything Skype related:
    Why are you having trouble signing in?
    I forgot my password
    I know my password, but can't sign in
    I think someone else is using my Microsoft account
    So I obviously choose the second option last time since it's the closest available option for my problem, but then it gives me options:
    Get back into your accountWe can help you reset your password and security info. First, enter your Microsoft account and the characters shown.
    So again it asked for my address and captcha, and after that I could choose to "verify my identity" by choosing the alt email, but since that is slight garbled and cannot be differented from the primary address, and I was already so pissed off from typing the same address over and over, so at that point I mistakenly wrote the main address again where it wanted to verify it by asking the whole alternative address and thus it never sent the account reset email for the Microsoft/Live account.
    But since I originally had no problems with that Microsoft account, all I wanted was the "Skype Name", and since the only way to try to find it jumps into the restore Microsoft account thing,  I'm assuming I don't have one which I could use to login to Skype, so all I can use is the Microsoft/Live account.

Maybe you are looking for