0

I have a backup script that contains several "sudo" commands. I don't want to have to type my username and password each time I run this script. So, I tried to add the "SUID" bit like this:

sudo chmod u+s <filename>

Now my file looks like this:

-rwsrwxr-x 1 root erelsgl 1868 Nov 12 09:03 <filename>

But, when I run the file, I still get a password prompt.

What am I doing wrong?

1

The problem is that ownership of your file is: user=root group=erelsgl.

User root belongs to root group.

So to fix your problem:

   chown root:root <filename>
   chmod u+s <filename>

After that you can remove sudo directive in your script.

I tested this on lubuntu 12.04.

Another better approach to this kind of problem is configure sudoers. Here is an example.

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.