runuser

Run commands as a specific user and group without asking for password (needs root privileges). More information: <https://manned.org/runuser>.

Install

All systems
curl cmd.cat/runuser.sh
Debian Debian
apt-get install util-linux
Ubuntu
apt-get install util-linux
Alpine
apk add util-linux
Arch Arch Linux
pacman -S util-linux
image/svg+xml Kali Linux
apt-get install util-linux
CentOS
yum install util-linux
Fedora
dnf install util-linux
Windows (WSL2)
sudo apt-get update sudo apt-get install util-linux
OS X
brew install util-linux
Raspbian
apt-get install util-linux
Docker
docker run cmd.cat/runuser runuser powered by Commando

Run commands as a specific user and group without asking for password (needs root privileges). More information: <https://manned.org/runuser>.

  • Run command as a different user:
    runuser user -c 'command'
  • Run command as a different user and group:
    runuser user -g group -c 'command'
  • Start a login shell as a specific user:
    runuser user -l
  • Specify a shell for running instead of the default shell (also works for login):
    runuser user -s /bin/sh
  • Preserve the entire environment of root (only if `--login` is not specified):
    runuser user --preserve-environment -c 'command'

© tl;dr; authors and contributors