Skip to content

tmpfiles

Parsing and serialization for tmpfiles.d configuration files, used to create, clean, and manage volatile files and directories at boot time.

import { parseTmpFilesConf, serializeTmpFilesConf } from '@sysopkit/linux/systemd/tmpfiles';
import type { TmpFilesConf, TmpFilesEntry, TmpfilesType } from '@sysopkit/linux/systemd/tmpfiles';
const entries = parseTmpFilesConf(`
d /run/myapp 0755 root root -
f /etc/myapp/config 0644 root root - "key=value"
`);
const content = serializeTmpFilesConf([
{ type: 'd', path: '/run/myapp', mode: '0755', user: 'root', group: 'root' },
{
type: 'f',
path: '/etc/myapp/config',
mode: '0644',
user: 'root',
group: 'root',
argument: 'key=value',
},
]);
type TmpFilesEntry = {
type: TmpfilesType;
path: string;
mode?: string | number;
user?: string;
group?: string;
age?: string;
argument?: string;
};
TypeAction
f / f+Create or truncate file
w / w+Write to existing file
d / DCreate directory (D also removes on --remove)
eClean existing directory contents
L / L+Create symlink
c / bCreate character/block device node
C / C+Copy files or directory trees
x / XIgnore path during cleanup
r / RRemove path (R recursive)
z / ZAdjust mode/ownership (Z recursive)
t / TSet extended attributes (T recursive)
h / HSet file attributes (H recursive)
a / ASet POSIX ACLs

Type modifiers: ! (boot-only), - (ignore errors), = (check file type), ~ (base64 argument).

FieldDescription
typeLine type determining the action.
pathAbsolute path for the file/directory.
modeFile access mode (octal, e.g. "0755").
user / groupOwner user and group.
ageTime-based cleanup age (e.g., "10d", "1w").
argumentContent for f/w types, symlink target for L, device major:minor for c/b.