Passwd is a placeholder Struct for user database on Unix systems.
contains the short login name of the user as a String.
contains the encrypted password of the user as a String. an 'x' is returned if shadow passwords are in use. An '*' is returned if the user cannot log in using a password.
contains the integer user ID (uid) of the user.
contains the integer group ID (gid) of the user’s primary group.
contains the path to the home directory of the user as a String.
contains the path to the login shell of the user as a String.
contains a longer String description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent.
password change time(integer).
quota value(integer).
password age(integer).
user access class(string).
comment(string).
account expiration time(integer).
static VALUE
etc_each_passwd(VALUE obj)
{
#ifdef HAVE_GETPWENT
RETURN_ENUMERATOR(obj, 0, 0);
each_passwd();
#endif
return obj;
} Iterates for each entry in the /etc/passwd file if a block is given.
If no block is given, returns the Enumerator.
The code block is passed an Passwd struct.
See Etc.getpwent above for details.
Example:
require 'etc'
Etc::Passwd.each {|u|
puts u.name + " = " + u.gecos
}
Etc::Passwd.collect {|u| u.gecos}
Etc::Passwd.collect {|u| u.gecos}
Ruby Core © 1993–2025 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.