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 Answers1

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.

Lety
  • 6,039
  • 2
  • 29
  • 37