This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

delete_user

Delete a user in ruby.
linux manual

Basic Usage

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

result = host.delete_user('kanrisuru')
result.success?
true

host.user?('kanrisuru')
false

Parameters

Field Type Description
user string
integer
Required name / uid of the user to delete.
force boolean
This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to remove the user's home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be removed, even if it is still the primary group of another user.

Result

No explicit data struct returned, only option is success?, failure?, and status to see if the program exited properly.

Exit Status

Code Description
0 Success
1 Can't update password file
2 Invalid command syntax
6 Specified user doesn't exist
8 User currently logged in
10 Can't update group file
12 Can't remove home directory

Tested On

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