12
6
Is there a way to switch user identity within a script (executed as root as part of an installation process) to execute some commands without calling an external script, then return to root
to run other commands?
Sort of:
#!/bin/bash
some commands as root
SWITCH_USER_TO user
some commands as user including environment variables checks, without calling an external script
SWITCH_USER_BACK
some other stuff as root, maybe another user id change...
Duplicate of How do I use su to execute the rest of the bash script as that user?
– Dan Dascalescu – 2014-07-11T11:36:11.283You should have a look at this answer http://stackoverflow.com/a/17758312/1243547
– Klaus – 2017-03-09T10:23:40.027