what is the linux cmd to get the SID

21,785

Solution 1

There's not a one-to-one mapping between those concepts. Linux users have permissions bases on their userid, effective userid, what groups they are in, and the resource they are trying to access.

You can see these as @fedorqui notes using id username

Note that if you're using selinux there is also the concept of users, and roles, where an SELinux user isn't the same as a user id. Not every linux system is running SELinux. You can see additional roles by running just id and it'll spit out selinux permissions as well as uid and group.

You can use id -Z for just selinux:

$ id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

Solution 2

I know this is an old thread but in case someone else stumbles upon it like I did here is a way to find SID's from the console using rpcclient. First login to rpcclient:

rpcclient -U "fred" 192.168.0.187 (replace user name and server IP accordingly)

Once logged in run this to find a users SID:

rpcclient $> lookupnames joe                                                    
joe S-1-5-21-2893105422-2373464063-1795470530-1000 (User: 1)

Hopefully someone else finds this useful. It took quite a bit of googling to find it. This info may be handy for troubleshooting Samba and ACL's.

Share:
21,785

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    If I want to get the SID of a particular user in windows. I would run the following cmd from a DOS windows:

    cmd> wmic useraccount get name,sid
    example output> kehelly S-1-5-21-3623811015-3361044348-30300820-1013
    

    SID: Security Identifier.

    When a user logs into a computer, their user SID and privileges are read. When this user requests access to a resource, the SID is checked and access is granted or denied depending on the SID.

    I am trying to get similar info on a linux machine. Does anyone know how to do this?

    • fedorqui
      fedorqui almost 11 years
      You can try with id user. It will give his UID, GID... (UID = user ID, GID= group ID).
    • Fred Foo
      Fred Foo almost 11 years
      The closest I can think of is id -u, which prints the effective user id. But I don't think that maps 1-on-1 to a Windows SID.
    • user229044
      user229044 almost 11 years
    • jelde015
      jelde015 over 2 years
      serverfault.com/questions/851864/… Check this out, this is how I was able to get the SID.
  • cmevoli
    cmevoli over 6 years
    Great solution, thanks. Also, you can use -W option for rpcclient to specify the domain. Also try lookupsids for the reverse.