2019-10-04 14:12:20 +01:00
|
|
|
# runuser
|
|
|
|
|
2024-02-14 20:25:13 +00:00
|
|
|
> Run commands as a user and group without asking for password (needs root privileges).
|
2022-03-21 17:07:48 +00:00
|
|
|
> More information: <https://manned.org/runuser>.
|
2019-10-04 14:12:20 +01:00
|
|
|
|
|
|
|
- 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}}'`
|