Skip to content
class method

Etc.getlogin

() -> ::String?
getlogin → String

Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin.

Avoid ::getlogin for security-related purposes.

If ::getlogin fails, try ::getpwuid.

See the unix manpage for getpwuid(3) for more detail.

e.g.

Etc.getlogin -> 'guest'
See also .getgrnam .getpwent .getgrgid .getpwnam also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0