Bash - Runuser

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Runuser - run a shell with substitute user and group IDs, similar to su, but will not run Linux Pluggable Authentication Modules (PAM) hooks

3 - Example

  • Basic
runuser -s /bin/bash $user -c " >/dev/null 2>&1 ; $*"
  • From the init library:
# make sure it doesn't core dump anywhere unless requested
corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
# if they set NICELEVEL in /etc/sysconfig/foo, honor it
[ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL"
# start
$nice runuser -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*"
Advertising