Skip to content

sysusers

Parsing and serialization for sysusers.d configuration files, used to declaratively create system users and groups at boot time.

import { parseSysusersConf, serializeSysusersConf } from '@sysopkit/linux/systemd/sysusers';
import type { SysusersConf, SysusersEntry, SysusersType } from '@sysopkit/linux/systemd/sysusers';
const entries = parseSysusersConf(`
u nginx - "Nginx web server" /var/lib/nginx /sbin/nologin
g myapp -
m alice myapp
`);
const content = serializeSysusersConf([
{
type: 'u',
name: 'nginx',
id: '-',
gecos: 'Nginx web server',
home: '/var/lib/nginx',
shell: '/sbin/nologin',
},
{ type: 'g', name: 'myapp' },
{ type: 'm', name: 'alice', id: 'myapp' },
]);
type SysusersEntry = {
type: 'u' | 'u!' | 'g' | 'm' | 'r';
name: string;
id?: string | number;
gecos?: string;
home?: string;
shell?: string;
};
TypeDescription
uCreate system user and group
u!Create user with fully locked account (no password auth)
gCreate system group only
mAdd user to group
rAdd UID/GID range to allocation pool
FieldDescription
nameUser or group name (1-31 chars, alphanumeric with _ and -).
idUID/GID, "-" for auto, or "uid:gid" format. For m type: the group name.
gecosUser description (GECOS field), only for u/u! types.
homeHome directory path, only for u/u! types.
shellLogin shell, only for u/u! types.