Kanrisuru

get_user

Gets a user in ruby
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = host.get_group('ubuntu')
result.success?
true

result.gid
1000

result.name
'ubuntu'

Parameters

Field Type Description
user string
Required name / uid of the user to get.

Result

Returns a single User struct.

User Fields

Field Type Description
uid integer The numerical value of the user's ID.
name string The name of the user
shell FilePath The name of the user's login shell.
home FilePath Location of the users home directory.
groups array Array of UserGroup structs, that define the all the groups a user belongs to.

Return Example

host.get_user(1000)
#<Struct:Kanrisuru::Core::User::User:0x00000640
  groups = [
    [ 0] #<Struct:Kanrisuru::Core::User::UserGroup:0x00000690
      gid = 1000,
      name = "ubuntu"
    >,
    [ 1] #<Struct:Kanrisuru::Core::User::UserGroup:0x000006e0
      gid = 4,
      name = "adm"
    >
  ],
  home = #<Struct:Kanrisuru::Core::User::FilePath:0x00000a50
    path = "/home/ubuntu"
  >,
  name = 'ubuntu',
  shell = #<Struct:Kanrisuru::Core::User::FilePath:0x00000aa0
    path = "/bin/zsh"
  >,
  uid = 1000
>

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES