Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I have a script, which contains some privileged commands (sudo ifup eth0 etc). And I want run this script without entering root password. Is there a way I ...
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    1

    bash script with root privileges

    Hi all,

    I have a script, which contains some privileged commands (sudo ifup eth0 etc). And I want run this script without entering root password. Is there a way I can do that? I heard about sticky bit and some other things that can do the trick...

    Thanks in advance

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,855
    I don't believe the modern kernel will allow you to setuid scripts, only binaries.

    Just use sudo to do it - put an entry in sudoers for the user to run the script, and use the NOPASSWD option, e.g.:

    Code:
    joeblow ALL = (root) NOPASSWD: /path/to/superscript.sh
    BTW, if running the script as root, you shouldn't need sudo commands inside the script itself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...