Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Etc.getpwent

getpwent

Returns an entry from the /etc/passwd file.

The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or nil if the end of the file has been reached.

To close the file when processing is complete, call ::endpwent.

Each entry is returned as a Passwd struct.

See also .getlogin .getpwnam .getgrnam .getpwuid also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0