Install
openclaw skills install @pinguy/privileged-operationsSafely perform Linux tasks that may require root privileges. Keep work unprivileged by default. When root is genuinely required, make the exact privileged action and reason visible to the user, then elevate only that narrow operation through an interactive authentication path the user can see and control. Prefer pkexec on graphical desktops; use sudo or doas only when their prompt is genuinely visible to the user. Never ask for, capture, pipe, cache, or automate a user's password, and never silently fall back to hidden or broad root execution.
openclaw skills install @pinguy/privileged-operationsSafely handle Linux work that crosses the root privilege boundary.
Stay unprivileged until one specific operation genuinely requires root. Show the user what needs root and why, then elevate only that operation through a visible, interactive authentication path.
Root access is not merely a technical capability. It is a human approval boundary.
The user should be able to notice:
Do not hide that boundary behind automation.
The default workflow is:
inspect as user
→ diagnose as user
→ download/build/generate as user
→ validate as user
→ identify the exact privileged step
→ show the user the command/action and reason
→ request visible interactive authentication
→ run only that privileged step
→ verify as user
Do not become root first and then perform the task.
Before elevating, be able to complete this sentence:
"This exact operation needs root because ________, and the rest of the task does not."
If the reason is unclear, investigate first.
Operations that normally stay unprivileged include:
$HOME;make, cmake, meson, ninja, cargo, Python, and Node project tooling;systemctl --user ...;makepkg, yay, and paru build/orchestration work that is designed to run as the normal user.Root may legitimately be needed for:
/etc, /usr, /opt, /boot, and similar paths;Even then, elevate only the protected operation.
Before a privileged mutation, surface the narrow action and reason to the user.
Good mental model:
Needs root: install validated config into /etc/example/
Privileged action: /usr/bin/install -Dm644 ./example.conf /etc/example/example.conf
Why: destination is root-owned
The wording does not need to be ritualistic, but the user must have enough information to understand what the authentication request corresponds to.
Do not trigger a password/authentication prompt with no visible context when the environment lets you explain first.
Authentication is approval for the stated operation, not blanket approval for unrelated later root work.
pkexecWhen a graphical polkit authentication agent is available, prefer:
pkexec <program> <arguments...>
This keeps the authentication step separate from the agent and normally gives the user a desktop approval/password dialog.
Prefer invoking the real executable directly:
pkexec /usr/bin/install -Dm644 ./example.conf /etc/example/example.conf
Avoid a privileged shell when a direct command works:
pkexec sh -c 'cp ./example.conf /etc/example/example.conf'
A privileged shell expands the authority and increases quoting and injection risk.
Before depending on pkexec, check that it exists. If no usable polkit authentication agent is available, report that rather than pretending the action was authorised.
sudo or doas may be acceptablesudo or doas may be used only when all of the following are true:
Do not use sudo or doas merely because pkexec is unavailable if their prompt would be hidden from the user.
Do not treat cached authentication as permission for unrelated root work. If the chosen mechanism would make the elevation invisible, stop and re-establish a visible approval boundary.
Never:
sudo -S;sshpass or equivalent password automation for local root elevation;The password belongs to the authentication system and the user, not to the agent.
Prefer one understandable root operation over a privileged command chain.
Good:
make
pkexec /usr/bin/make install
Riskier:
pkexec /bin/bash
make
make install
The second version unnecessarily gives the entire build root authority and can leave root-owned files in the user's work tree.
Avoid:
pkexec sh -c 'command1 && command2 && command3 && command4'
when only part of the chain needs root.
Do not start a persistent root shell by default. Treat an interactive root shell as exceptional and use it only when the user explicitly wants that mode and the work cannot reasonably be reduced to bounded commands.
The goal is not the fewest prompts. The goal is the smallest understandable privilege boundary.
Privilege tools often use a different or restricted environment. Do not assume preservation of:
PATH;HOME;Resolve important paths before elevation and pass explicit arguments.
For sensitive commands, prefer known absolute executable paths where practical:
command -v systemctl
pkexec /usr/bin/systemctl restart example.service
Quote paths and variables, and use -- before path operands where supported:
pkexec /usr/bin/rm -- "$file"
Do not trust a project-local executable merely because its name resembles a system program.
Keep compilation, downloads, code generation, project scripts, extraction, and testing unprivileged.
Preferred pattern:
build as user → test as user → validate → elevate final protected install → verify as user
This avoids root-owned build artefacts, poisoned user caches, and arbitrary build scripts running with full system access.
If a privileged operation unexpectedly creates root-owned files inside a user work tree, identify the exact affected paths and repair only those paths.
Never use a broad repair such as:
pkexec chown -R "$USER:$USER" "$HOME"
That can damage files intentionally owned by root or another user.
Never run user-oriented build helpers as root merely to bypass their privilege model.
On Arch-family systems, for example:
Example:
makepkg
pkexec /usr/bin/pacman -U ./package-name-*.pkg.tar.zst
pacman -Q package-name
A direct system package transaction may legitimately require root:
pkexec /usr/bin/pacman -S --needed package-name
If a visible terminal workflow is deliberately being used instead, the equivalent sudo/doas command is acceptable only under the interactive-visibility rules above.
Before broad installs, upgrades, or removals, inspect the proposed transaction. Do not add non-interactive confirmation flags by default to potentially destructive package operations.
Determine whether a unit is user-level or system-level before elevating.
# user unit
systemctl --user restart example.service
# system unit on a desktop with polkit
pkexec /usr/bin/systemctl restart example.service
Do not elevate user services unnecessarily.
After changing a system unit, reload only when needed, then perform the exact intended action: start, stop, restart, reload, enable, disable, mask, or unmask. These are not interchangeable.
Verify afterwards:
systemctl status example.service
journalctl -u example.service -n 50 --no-pager
If reading the journal itself requires root, elevate only that read operation.
Avoid launching a full editor as root.
Use this pattern:
Example:
cp /etc/example.conf ./example.conf.new
# edit and validate ./example.conf.new
diff -u /etc/example.conf ./example.conf.new
pkexec /usr/bin/cp -a /etc/example.conf /etc/example.conf.bak
pkexec /usr/bin/install -m 644 ./example.conf.new /etc/example.conf
Adapt ownership, permissions, ACLs, extended attributes, security labels, and other metadata to the actual target. 0644 is not universally correct.
Before overwriting a protected target, determine whether it is a file, directory, symlink, mount point, generated file, or package-owned file.
Prefer supported overrides, drop-ins, /etc configuration, or /usr/local installation over directly editing package-owned vendor files under /usr.
Shell redirection may happen before the elevated program starts, so this is wrong:
pkexec echo "value" > /etc/example.conf
For a short stream, narrowly scoped tee may be appropriate:
printf '%s\n' "value" | pkexec /usr/bin/tee /etc/example.conf >/dev/null
For non-trivial files, generate and validate the file as the normal user, then install it with a narrow privileged command.
Do not download changing remote content directly into protected system paths as root.
Prefer:
download as user → verify → inspect/extract/build as user → elevate final install only
Avoid:
curl ... | pkexec sh
curl ... | sudo sh
If upstream documentation says the whole installer must run as root:
An interactive password prompt does not make an opaque root installer safe.
Do as much validation as possible before elevation: syntax checks, diffs, unit verification, package state, hashes/signatures where applicable, free space, binary tests, destination checks, and device/mount checks.
For configuration changes, prefer:
generate → diff → validate → backup → privileged install → validate again
For risky changes, know the rollback path before applying them.
If rollback is difficult or impossible, say so before making the change.
Treat privileged destructive commands as high risk, especially:
rm -rf, recursive chmod, or recursive chown;dd, mkfs.*, fdisk, sfdisk, parted, or wipefs;systemctl disable or mask;/boot, or EFI operations;Before running them:
Never construct a privileged recursive deletion from an unchecked variable.
Never guess between ambiguous destructive targets. If the target cannot be established confidently, stop rather than choosing one.
Never solve privilege friction by permanently making the system less secure.
Do not:
A visible one-time authentication step is preferable to a permanent privilege hole.
Authentication success does not prove the command succeeded.
After every privileged change, inspect the exit status and verify the resulting state.
If a privileged operation fails:
Do not stack more privileged changes on top of an unknown partial state.
Prefer idempotent commands where practical, and check before appending settings that could duplicate on rerun.
pkexec when a graphical polkit prompt is available.sudo/doas only through a genuinely user-visible interactive terminal path.