Run command as Linux "system" user (shell = /bin/false)
Solution 1:
I use su - targetuser -s /bin/bash
from a root shell.
For direct command execution use -c
:
su - targetuser -s /bin/bash -c "/bin/echo hello world"
Solution 2:
Use sudo. This will work even if the user doesn't have a real shell.