Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!.
improved formatting; clarified what's needed
Source Link
Cristian Ciupitu

I got a script rquiringrequiring sudo, but the script must set parameters according to the original user, such as:

chown "${USER}:${USER}" dir

chown "${USER}:${USER}" dir

If I set it under sudo, I just end up with "chmod root:root"chmod root:root, which doesn't help.

HowSo how can I do that get the user name before sudo?

I got a script rquiring sudo, but the script must set parameters according to the original user, such as:

chown "${USER}:${USER}" dir

If I set it under sudo, I just end up with "chmod root:root", which doesn't help.

How can I do that ?

I got a script requiring sudo, but the script must set parameters according to the original user, such as:

chown "${USER}:${USER}" dir

If I set it under sudo, I just end up with chmod root:root, which doesn't help.

So how can I get the user name before sudo?

Source Link
Bite code

User name before sudo

I got a script rquiring sudo, but the script must set parameters according to the original user, such as:

chown "${USER}:${USER}" dir

If I set it under sudo, I just end up with "chmod root:root", which doesn't help.

How can I do that ?

lang-bash