Skip to content

Instantly share code, notes, and snippets.

@jamesbjackson
Forked from staaldraad/uid_awk.sh
Created December 21, 2017 10:08
Show Gist options
  • Save jamesbjackson/316a8c27ff7d03b916daffc8a8c92af2 to your computer and use it in GitHub Desktop.
Save jamesbjackson/316a8c27ff7d03b916daffc8a8c92af2 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment