I have a script with name "somescript", which has executable permissions for everyone (755) but when I try to run it with a non-root user it keeps asking root password. I even tried setting to 4755 with no luck. Only admin user and user with root password run the script currently.

How can I make it so that, any user can run the script (but not change it)

-rwxr-xr-x 1 root     group1 2841 Jul  8  2014 somescript

user@node:~> somescript
root's password:

Edit: After tring Setuid and Setgid and seeing them not working I inspected more through script and found out script is checking for user name root, if not executing via sudo which forces to use root password. Commenting out this script should make it work via setting setuid as its owner is root.

if [ "$uid" != "root" ]
  exec sudo /someplace/somescript
  • 2
    Maybe it is soemthing in the script, that needs elevated privileges? Jan 6, 2016 at 8:38

1 Answer 1


Probably the script is asking for some operation with root privileges, which has nothing to do with permissions (in this case) as this operation will be performed by the current user and you don't have the SETUID or SETGID bits enabled.

You can, however, activate the SETUID bit on the script. This will make the script be run with the owner user, in your case root, but the user running the script doesn't need to perform any privileges elevation.

You can do this by running:

chmod u+s somescript

More on SETUID/SETGID: Understand the setuid and setgid permissions to improve security

  • Thanks, found out problem was inside the script made with a root check, added solution on my question.
    – Gorkem
    Jan 6, 2016 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.