Linux command
runuser 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
runuser [user] -c '[command]'
Example
runuser [user] -g [group] -c '[command]'
Example
runuser [user] -l
Example
runuser [user] -s /bin/bash
Preserve
runuser [user] -p -c '[command]'
说明
runuser runs commands as another user without requiring password authentication. Unlike su, it's designed for use by root in system scripts and services where interactive authentication isn't appropriate. The tool is commonly used in init scripts and system services to drop privileges to a specific user before executing commands.
参数
- -c, --command _command_
- Command to execute
- -g, --group _group_
- Specify group
- -l, --login
- Start login shell
- -s, --shell _shell_
- Use specific shell
- -p, --preserve-environment
- Keep environment variables
- -w, --whitelist-environment
- Preserve specific variables
FAQ
What is the runuser command used for?
runuser runs commands as another user without requiring password authentication. Unlike su, it's designed for use by root in system scripts and services where interactive authentication isn't appropriate. The tool is commonly used in init scripts and system services to drop privileges to a specific user before executing commands.
How do I run a basic runuser example?
Run `runuser [user] -c '[command]'` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --command _command_ do in runuser?
Command to execute