W3cubDocs

/Crystal

class System::User

Overview

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

Defined in:

system/user.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.find_by(*, name : String)Source

Returns the user associated with the given username.

Raises NotFoundError if no such user exists.

def self.find_by(*, id : String)Source

Returns the user associated with the given ID.

Raises NotFoundError if no such user exists.

def self.find_by?(*, name : String)Source

Returns the user associated with the given username.

Returns nil if no such user exists.

def self.find_by?(*, id : String)Source

Returns the user associated with the given ID.

Returns nil if no such user exists.

Instance Method Detail

def ==(other : self)

Description copied from class Reference

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

def group_id : StringSource

The user's primary group identifier.

def hash(hasher)

Description copied from class Reference

See Object#hash(hasher)

def home_directory : StringSource

The user's home directory.

def id : StringSource

The user's identifier.

def name : StringSource

The user's real or full name.

def shell : StringSource

The user's login shell.

def to_s(io)Source

def username : StringSource

The user's username.

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/System/User.html