Create, remove, and check system users on Linux, macOS, and Windows.
Part of Nodevisor — TypeScript Infrastructure Automation Platform
npm install @nodevisor/usersimport $ 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');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"| 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 |
@nodevisor/auth— Set user passwords@nodevisor/groups— Manage group membership@nodevisor/authorized-keys— Manage SSH keys for users
Full documentation available at nodevisor.com/docs/packages/users
Nodevisor uses a single O'Saasy license across all packages and applications. See the full terms in LICENSE.
