The su (substitute user) command can be used to impersonate other users on the system. su is provided by the sys-apps/shadow package. It is also included with the sys-apps/util-linux package, but it is disabled in the ebuild to prevent a file collision with sys-apps/shadow.
su will run commands as root by default. Since not specifying a username will cause su to ask for root privileges, the following command will run as root and halt the system:
su -c 'shutdown -h now'
It is best practice to encapsulate the commands following the
-coption with either single or double quotes.
It is also possible to specify a user other than root to substitute commands. The following example will run the command echo as the user larry:
su -c 'echo "Moo to the Gentoo Wiki reader out there!"' larry