I have a script that runs with root privileges, and I have a command that must not be run with the those privileges that is executed by the script. I need a way to run that command without those privileges.
From what I’ve been able to determine, I can run a command as another user using tools like sudo. But doing so requires the knowledge of the user name (or ID) that is to be used before hand. This also raises one or two security issues.
My question is: Is it possible to simply run that command as root but without the elevated privileges? if not, are there suitable alternatives?
You can indeed use
sudoto run the command with lowered privileges like this:or better
Note that this will require proper entries in the
sudoersfile.If you don’t know the name of a user and would like to just run the command with some lowered privileges you can use user
nobodyand groupnobodyornogroupfor that.