gnmajw
Last Updated: February 26, 2016
·
371
· domon
3fe8ae238c14d716a9fc16734a70765b

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.

Say Thanks
Respond