Skip to content

sudo

Run direct commands or block-scoped operations with elevated privileges via sudo.

Functions

run cmd *args … -> nil

Runs a verbatim command through sudo.

Parameters

NameTypeDescription
cmd Program to run.
:user? Str Account to use instead of root.
:cd? (Str | fs.Path) Working directory requested via sudo.
:env? Dict[Str | Sym, Value] Environment requested via sudo policy.
*args Arguments passed verbatim to cmd.

Example

sudo.run install -m 0644 example.conf /etc/example.conf

with[R] func … -> R

Runs a block with elevated privileges through sudo.

Filesystem access and spawned programs use a temporary elevated VFS for the duration of the block. Pass user to run as an account other than root.

Parameters

NameTypeDescription
func (() -> R) Block to run.
:user? Str Account to use instead of root.
:cd? (Str | fs.Path) Initial elevated directory.
:env? Dict[Str | Sym, Value] Initial environment overrides.

Example

sudo.with do run cat /etc/shadow