Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Nodevisor Logo

@nodevisor/users

Create, remove, and check system users on Linux, macOS, and Windows.

Part of Nodevisor — TypeScript Infrastructure Automation Platform

Install

npm install @nodevisor/users

Quick Start

import $ from '@nodevisor/shell';
import Users from '@nodevisor/users';

const users = $(Users);

// Check current user
const me = await users.whoami(); // "root"

// Create a new user
if (!(await users.exists('runner'))) {
  await users.add('runner');
}

// Remove a user
await users.remove('olduser');

Remote Usage

const $server = $.connect({ host: '10.0.0.10', username: 'root' });

await $server(Users).add('runner');

// Switch to the new user context
const $runner = $server.as('runner');
const whoami = await $runner`whoami`.text(); // "runner"

API

Method Description
whoami() Get the username of the current user
exists(username) Check if a user exists on the system
add(username) Create a new system user
remove(username) Remove a system user

Related Packages

Documentation

Full documentation available at nodevisor.com/docs/packages/users

License

Nodevisor uses a single O'Saasy license across all packages and applications. See the full terms in LICENSE.