2019-10-04 20:12:20 +07:00
|
|
|
# runuser
|
|
|
|
|
2024-02-14 17:25:13 -03:00
|
|
|
> Run commands as a user and group without asking for password (needs root privileges).
|
2022-03-22 03:07:48 +10:00
|
|
|
> More information: <https://manned.org/runuser>.
|
2019-10-04 20:12:20 +07:00
|
|
|
|
|
|
|
- Run command as a different user:
|
|
|
|
|
2025-03-28 16:06:49 +02:00
|
|
|
`runuser {{user}} {{[-c|--command]}} '{{command}}'`
|
2019-10-04 20:12:20 +07:00
|
|
|
|
|
|
|
- Run command as a different user and group:
|
|
|
|
|
2025-03-28 16:06:49 +02:00
|
|
|
`runuser {{user}} {{[-g|--group]}} {{group}} {{[-c|--command]}} '{{command}}'`
|
2019-10-04 20:12:20 +07:00
|
|
|
|
|
|
|
- Start a login shell as a specific user:
|
|
|
|
|
2025-03-28 16:06:49 +02:00
|
|
|
`runuser {{user}} {{[-l|--login]}}`
|
2019-10-04 20:12:20 +07:00
|
|
|
|
|
|
|
- Specify a shell for running instead of the default shell (also works for login):
|
|
|
|
|
2025-03-28 16:06:49 +02:00
|
|
|
`runuser {{user}} {{[-s|--shell]}} {{/bin/sh}}`
|
2019-10-04 20:12:20 +07:00
|
|
|
|
|
|
|
- Preserve the entire environment of root (only if `--login` is not specified):
|
|
|
|
|
2025-03-28 16:06:49 +02:00
|
|
|
`runuser {{user}} {{[-p|--preserve-environment]}} {{[-c|--command]}} '{{command}}'`
|