Getting system user or group ids by their names with Ruby
It can be done by calling getpwnam(3)
and getgrnam(3)
.
require 'etc'
Etc.getpwnam('root').uid # => 0
Etc.getgrnam('nogroup').gid # => 65534
For more information, please see the documentation Etc module.
Written by Chun-wei Kuo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#