学习啦 > 学习电脑 > 操作系统 > Linux教程 > linux的runuser命令

linux的runuser命令

时间: 佳洲1085 分享

linux的runuser命令

  Linux下runuser命令不太经常用到,我们需要了解他的用法即可。下面由学习啦小编为大家整理了linux下runuser命令的相关知识,希望对大家有帮助!

  linux的runuser命令详解

  runuser --help

  用法:runuser [选项]... [-] [用户 [参数]... ]

  Change the effective user id and group id to that of USER. Only session PAM

  hooks are run, and there is no password prompt. This command is useful only

  when run as the root user. If run as a non-root user without privilege

学习啦在线学习网   to set user ID, the command will fail as the binary is not setuid.

  As runuser doesn't run auth and account PAM hooks, it runs with lower overhead

  than su.

  -, -l, --login make the shell a login shell, uses runuser-l

学习啦在线学习网   PAM file instead of default one

  -g --group=group specify the primary group

学习啦在线学习网   -G --supp-group=group specify a supplemental group

  -c, --command=COMMAND pass a single COMMAND to the shell with -c

  --session-command=COMMAND pass a single COMMAND to the shell with -c

  and do not create a new session

  -f, --fast pass -f to the shell (for csh or tcsh)

  -m, --preserve-environment do not reset environment variables

学习啦在线学习网   -p same as -m

学习啦在线学习网   -s, --shell=SHELL run SHELL if /etc/shells allows it

  --help 显示此帮助信息并退出

学习啦在线学习网   --version 显示版本信息并退出

  单独的"-"选项隐含了-l。如果不指定用户,则假设其为root。

学习啦在线学习网   请向bug-coreutils@gnu.org 报告runuser 的错误

学习啦在线学习网   GNU coreutils 项目主页:<http://www.gnu.org/software/coreutils/>

  GNU 软件一般性帮助:<http://www.gnu.org/gethelp/>

学习啦在线学习网   请向<http://translationproject.org/team/zh_CN.html> 报告runuser 的翻译错误

学习啦在线学习网   要获取完整文档,请运行:info coreutils 'runuser invocation'

  linux的runuser命令使用实例

  # For SELinux we need to use 'runuser' not 'su'

学习啦在线学习网   if [ -x "/sbin/runuser" ]; then

学习啦在线学习网   SU="/sbin/runuser -s /bin/sh"

  else

学习啦在线学习网   SU="/bin/su -s /bin/sh"

  fi

3630594