Skip to content

Instantly share code, notes, and snippets.

@mikroskeem
Created August 23, 2023 15:11
Show Gist options
  • Save mikroskeem/3ca24a2eed78d0b101842a1eabf6f97f to your computer and use it in GitHub Desktop.
Save mikroskeem/3ca24a2eed78d0b101842a1eabf6f97f to your computer and use it in GitHub Desktop.
Inspect systemd service namespace
#!/usr/bin/env bash
set -euo pipefail
svc="${1}"
pid="$(systemctl show --property MainPID --value "${svc}")"
user="$(systemctl show --property User --value "${svc}")"
uid="$(getent passwd "${user}" | cut -d: -f3)"
sudo nsenter -t "${pid}" -U -m -S "${uid}" /bin/bash -i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment