Forrest logo
back to the runuser tool

runuser:tldr:4e679

runuser: Preserve the entire environment of root (only if `--login` is not specified).
$ runuser ${user} --preserve-environment -c '${command}'
try on your machine

The given command is a shell command used to run a specific command as a different user while preserving the environment variables of the current user.

Let's break down the command:

  • runuser: It is a command used to run a command with substitute user and group credentials.
  • ${user}: It is a placeholder variable that should be replaced with the desired username. This specifies the user whose privileges you want to use to run the command.
  • --preserve-environment: This flag tells the runuser command to preserve the environment variables of the current user and pass them to the new user.
  • -c '${command}': This option followed by the desired command enclosed within single quotes runs the specified command as the given user.

In summary, by using this command, you can run the specified command as a different user while keeping the current user's environment variables intact. The ${user} placeholder should be replaced with the actual username, and the ${command} placeholder should be replaced with the desired command.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the runuser tool