Skip to content

Instantly share code, notes, and snippets.

@staaldraad
Created December 12, 2017 14:06
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save staaldraad/640b22ac11f8f37872cdddf7c4bdf11f to your computer and use it in GitHub Desktop.
Save staaldraad/640b22ac11f8f37872cdddf7c4bdf11f to your computer and use it in GitHub Desktop.
Get the uid, gid and user groups without touching /etc/passwd or running the `id` command
awk -F: 'END {print "uid:"u" gid:"g" groups:"gg}{if($1=="Uid"){split($2,a," ");u=a[1]}if($1=="Gid"){split($2,a," ");g=a[1]}if($1=="Groups"){gg=$2}}' /proc/self/status
@zerolagtime
Copy link

Ditto. This is gold in a stripped down container or environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment