Terminal decrease privileges

106 views Asked by At

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`;

1

There are 1 answers

0
Aaron Digulla On

When you're root, you can use sudo -u user cmd... to run a command as user. Since you're already root, it won't ask for a password.