Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I would like to have a program started as root everytime it is being used: without sudo or password. Is it possible? If yes how? I tried using aliases: ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6

    Starting a program as root without sudo

    Hi,
    I would like to have a program started as root everytime it is being used: without sudo or password. Is it possible? If yes how?

    I tried using aliases: prg 'sudo prg', but I am not satisfied with this solution. Can somebody suggest something different?

    The reason for that is I need to start gdb from an IDE (eclipse) and the application I am developing need to be run as root so I need to have gdb always run as root whichever way it is started.

    I hope I made the problem clear...

    Regards,

    Anne

  2. #2
    Trusted Penguin Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,392
    You can do 'chmod u+s ...' for the app, but I don't recommend it.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6
    I tried using this:
    setuid(0); + modifying the executable so that it is owned by root and has s bit set.
    Problem is this sort of approach does not seem to work with the debugger. I think I need to start the debugger as root and the rest will follow: the application will get root privileges.
    Am I right? or did I misunderstand your reply?

  4. #4
    Linux Enthusiast flipjargendy's Avatar
    Join Date
    Aug 2004
    Location
    Xanadu, Titan, Saturn
    Posts
    610
    i assume you are running into the problem where the application will not start when you are using 'sudo'. If that is the case you could just type 'sudo bash'. You now have root access to anything you do in the command line.

    The command line you are in is "Bash". So you are actually running Bash with sudo now. Anything you try to run will most likely start up just fine and you'll have root capabilities with it.

    Hope this is what you were looking for, although after re-reading your post, i'm not sure it is.
    Running Linux Since 2001®
    Registered Linux User #430868 - Since 9•12•06

  5. #5
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6
    I wish it could be that simple... I tried making a shell script: (gdb_root.sh)

    #!/bin/bash
    #
    sudo gdb $*

    and calling this script from the ide instead of gdb but somehow eclipse does not like that... I also posted the problem on the eclipse newsgroup.

    I don't think there is a problem with the script just that eclipse doesn't like starting a shell script instead of the debugger...
    Thanks anyway!

  6. #6
    Linux Enthusiast flipjargendy's Avatar
    Join Date
    Aug 2004
    Location
    Xanadu, Titan, Saturn
    Posts
    610
    maybe you could start out by getting doing kind of what i said, tell the script 'sudo bash' then once it does that start the application you're trying to start. i know some apps don't run properly when you sudo them and some don't even start. It might help.
    Running Linux Since 2001®
    Registered Linux User #430868 - Since 9•12•06

  7. #7
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6
    Silly me!
    The solution explained above (starting a script instead of the program itself) DOES work, you just have to make sure that the script has executable permissions...
    Hum... Let put that under the fact that I am still pretty new to linux...
    Thanks everybody for the help, it was greatly appreciated!
    Anne

Posting Permissions

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