Skip to content

class System::User
inherits Reference

Represents a user on the host system.

Users can be retrieved by either username or their user ID:

require "system/user"

System::User.find_by name: "root"
System::User.find_by id: "0"

Extended modules

Crystal::System::User

Class methods

.find_by(*, name : String)

Returns the user associated with the given username.

Raises NotFoundError if no such user exists.

View source

.find_by(*, id : String)

Returns the user associated with the given ID.

Raises NotFoundError if no such user exists.

View source

.find_by?(*, name : String)

Returns the user associated with the given username.

Returns nil if no such user exists.

View source

.find_by?(*, id : String)

Returns the user associated with the given ID.

Returns nil if no such user exists.

View source

Methods

#==(other : self)

Returns true if this reference is the same as other. Invokes same?.

#group_id : String

The user's primary group identifier.

View source

#hash(hasher)

#home_directory : String

The user's home directory.

View source

#id : String

The user's identifier.

View source

#name : String

The user's real or full name.

View source

#shell : String

The user's login shell.

View source

#to_s(io)

View source

#username : String

The user's username.

View source