Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Setting a program to run at startup as root

  1. #1
    Join Date
    Mar 2007
    Beans
    35

    Setting a program to run at startup as root

    I want to run wondershaper at startup but it requires that I run it as sudo. So how would I go about having the command run at startup?

    ie. sudo wondershaper eth1 x x

  2. #2
    Join Date
    Feb 2008
    Beans
    5,636

    Re: Setting a program to run at startup as root

    Add the command to /etc/rc.local

  3. #3
    Join Date
    Oct 2010
    Location
    Prague
    Beans
    263
    Distro
    Ubuntu UNR

    Re: Setting a program to run at startup as root

    Quote Originally Posted by d58e7 View Post
    I want to run wondershaper at startup but it requires that I run it as sudo. So how would I go about having the command run at startup?

    ie. sudo wondershaper eth1 x x
    Go to your terminal and type sudo visudo. A text file will pop out in your terminal, go to the line where's

    Code:
    root    ALL=(ALL) ALL
    in ubuntu under 'root ALL=(ALL) ALL' there should be a line like 'user.name ALL=(ALL) ALL' probably looking like this

    Code:
    root    ALL=(ALL) ALL
    user.name    ALL=(ALL) ALL
    anyway under the line 'root ALL=(ALL) ALL' you should write a line that would look like this

    Code:
    root    ALL=(ALL) ALL
    user.name   ALL=NOPASSWD: /path_to_your_program_bin_file
    where user.name it's the name u are using to log in. After editind press F2 and enter to confirm saving. What this will do it's that when you will use sudo no password will be required and this will help you to run that program of yours at startup.

    !!! I've modified my post 'cause I have to agree it's not safe to advise anybody to do that. So the proper way to do this would be "user.name ALL=NOPASSWD: /path_to_your_program_bin_file" so only that program could be executed with sudo without the use of a password. Sorry for doing a post that could had endangered your PC especially if you're connected at a local network> I didn't thought much at that moment 'cause I have this bad habit to believe most people have the same Internet connection as I do, the same PC configurations and so on, though I know this it's impossible that's my first impressiom he he Cheers
    Last edited by I'mGeorge; November 1st, 2010 at 12:56 AM.
    Debian rulz but Ubuntu it's alright either

  4. #4
    Join Date
    Feb 2008
    Beans
    5,636

    Re: Setting a program to run at startup as root

    Quote Originally Posted by I'mGeorge View Post
    Go to your terminal and type sudo visudo. A text file will pop out in your terminal, go to the line where's

    Code:
    root    ALL=(ALL) ALL
    in ubuntu under 'root ALL=(ALL) ALL' there should be a line like 'user.name ALL=(ALL) ALL' probably looking like this

    Code:
    root    ALL=(ALL) ALL
    user.name    ALL=(ALL) ALL
    anyway under the line 'root ALL=(ALL) ALL' you should write a line that would look like this

    Code:
    root    ALL=(ALL) ALL
    user.name   ALL=NOPASSWD: ALL
    where user.name it's the name u are using to log in. After editind press F2 and enter to confirm saving. What this will do it's that when you will use sudo no password will be required and this will help you to run that program of yours at startup.
    Won't this compromise his whole system?

  5. #5
    Join Date
    Sep 2005
    Beans
    319

    Re: Setting a program to run at startup as root

    Look into changing the permissions on the executable. Applications should not be running as root, however you can create a special user that has the permissions required for the application. Look through the /etc/passwd file and you'll see many "users" with specific permission sets. That's the way we do it.

    Having said that, I do run some applications as root, but I understand that if I were doing it right, I would never have to.

  6. #6
    Join Date
    Sep 2007
    Location
    Oklahoma, USA
    Beans
    2,378
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Setting a program to run at startup as root

    Yes, it will. Preferable solution is to add the command to /etc/rc.local, just in front of the line in that file that reads "exit 0" and without the "sudo" at the front. The rc.local file runs at boot time, as root. Also, if the program is not in the "usual" program locations known to the boot process, it will need its full pathname rather than just "wondershaper" so that the process can find it.
    Last edited by JKyleOKC; October 31st, 2010 at 07:46 PM. Reason: to fix a typo
    --
    Jim Kyle in Oklahoma, USA
    Linux Counter #259718
    Howto mark thread: https://wiki.ubuntu.com/UnansweredPo.../SolvedThreads

  7. #7
    Join Date
    Oct 2010
    Location
    Prague
    Beans
    263
    Distro
    Ubuntu UNR

    Re: Setting a program to run at startup as root

    Quote Originally Posted by TeoBigusGeekus View Post
    Won't this compromise his whole system?
    It depends, but mostly it should be alright
    Debian rulz but Ubuntu it's alright either

  8. #8
    Join Date
    Dec 2009
    Beans
    6,816

    Re: Setting a program to run at startup as root

    Since I had no idea what wondershapper was I googled it and it sent me back here:
    http://ubuntuforums.org/showthread.php?t=25911

    See if that makes any sense.

    If not and since this is a networking application you might consider creating a script and adding it to:
    Code:
    /etc/network/if-up.d
    Any script added to that directory will be run (by root so you don't need the "sudo" part) only after the network is up.

  9. #9
    Join Date
    Oct 2010
    Beans
    71

    Re: Setting a program to run at startup as root

    Quote Originally Posted by holiday View Post
    Look into changing the permissions on the executable. Applications should not be running as root, however you can create a special user that has the permissions required for the application. Look through the /etc/passwd file and you'll see many "users" with specific permission sets. That's the way we do it.

    Having said that, I do run some applications as root, but I understand that if I were doing it right, I would never have to.
    Surely you need root to run some applications? That's the entire reason root is there... so you can do stuff that needs root privs (like install software).
    Angus

  10. #10
    Join Date
    Nov 2006
    Location
    UK, London. Wapping.
    Beans
    769
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Setting a program to run at startup as root

    Quote Originally Posted by Morbius1 View Post
    Since I had no idea what wondershapper was I googled it and it sent me back here:
    http://ubuntuforums.org/showthread.php?t=25911

    See if that makes any sense.
    +1

    This seems like the best solution to me and it'll work.

    Don't change permissions as indicated earlier.

    If you want to run an sudo command at startup use crontab. This would run RKHunter.

    sudo crontab -e

    @reboot /usr/bin/sudo rkhunter -c -sk


    Here's an excellent crontab guide.

    https://help.ubuntu.com/community/CronHowto
    Last edited by ayenack; October 31st, 2010 at 08:32 PM.
    The Other Ubuntu Search Engine touse
    Before following advice look at this.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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