Use chmod +s <filename>Use chmod +s <filename> to se the suid bit. This means that when the file is executed, it runs with the permissions of the owner of the file (so chown it to root to make it run as that).
However, this can be VERY dangerous with something like a bash scripts, because a user finds a way to change it, they can easily gain a root shell. Make sure that it can't be written to by anyone except root.
Linux doesn't allow you to se the suid bit. This means that when the file is executedsetuid on scripts, it runs with the permissions of the owner of the file (so chown it to rootdo this you'd have to makecompile it run as that)a program.
However Instead, thisyou can be VERY dangerous with something like a bash scripts, because a user finds a way to change ituse the sudoers file (/etc/sudoers), they can easily gainand add a root shell. Make sure that it can't be written to by anyone except rootline like this.
<username> ALL = NOPASSWD: /path/to/script