Currently I'm working on a perl script (for Debian based OS'es) that automatically installs some software packages. Therefore the script needs root privileges. As you all know this can be done by adding sudo
before the command.
For some configurations however, the terminal user may not be the root. So my question is, how can I decrease the privileges and return to the user that opened the terminal.
I already tried the following code, but it closes the terminal and thats not what I want.
$result = `exit`;
When you're root, you can use
sudo -u user cmd...
to run a command asuser
. Since you're already root, it won't ask for a password.