commands.sh

runuser

linux

Run commands as a user and group without asking for password.

More info →

Options (5)

-c, --commandboolean

Run command as a different user

Example: sudo runuser {{user}} {{[-c|--command]}} '{{command}}'
-g, --groupboolean

Run command as a different user and group

Example: sudo runuser {{user}} {{[-g|--group]}} {{group}} {{[-c|--command]}} '{{command}}'
-l, --loginboolean

Start a login shell as a specific user

Example: sudo runuser {{user}} {{[-l|--login]}}
-s, --shellboolean

Specify a shell for running instead of the default shell (also works for login)

Example: sudo runuser {{user}} {{[-s|--shell]}} {{/bin/sh}}
-p, --preserve-environmentboolean

Preserve the entire environment of root (only if `--login` is not specified)

Example: sudo runuser {{user}} {{[-p|--preserve-environment]}} {{[-c|--command]}} '{{command}}'

Examples (5)

Run command as a different user

sudo runuser user [-c|--command] 'command'

Run command as a different user and group

sudo runuser user [-g|--group] group [-c|--command] 'command'

Start a login shell as a specific user

sudo runuser user [-l|--login]

Specify a shell for running instead of the default shell (also works for login)

sudo runuser user [-s|--shell] /bin/sh

Preserve the entire environment of root (only if `--login` is not specified)

sudo runuser user [-p|--preserve-environment] [-c|--command] 'command'
made by @shridhargupta | data from tldr-pages