class

System::User

Inherits Crystal::System::User / Reference / Object

Represents a user on the host system.

NOTE: To use User, you must explicitly import it with require "system/user"

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"

Class methods

find_by(*, name : String) : System::User

Returns the user associated with the given username.

Raises NotFoundError if no such user exists.

Source
find_by(*, id : String) : System::User

Returns the user associated with the given ID.

Raises NotFoundError if no such user exists.

Source
find_by?(*, name : String) : System::User | Nil

Returns the user associated with the given username.

Returns nil if no such user exists.

Source
find_by?(*, id : String) : System::User | Nil

Returns the user associated with the given ID.

Returns nil if no such user exists.

Source

Instance methods

==(other : self)

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

group_id

The user's primary group identifier.

Source
hash(hasher)

See Object#hash(hasher)

home_directory

The user's home directory.

Source
id

The user's identifier.

Source
name

The user's real or full name.

May not be present on all platforms. Returns the same value as #username if neither a real nor full name is available.

Source
shell

The user's login shell.

Source
to_s(io)
Source
username

The user's username.

Source

Nested types