7

I have an application (VirtualBox) which I need to run as root user. I can run sudo VirtualBox just fine, but I want to have a shortcut on my Desktop which I only have to click on to start VirtualBox as root user. I tried chown root:root, but that doesn't do anything.

Thanks!

Btw: I'm running Debian Squeeze.

LinuxNewbie
  • 73
  • 1
  • 1
  • 3
  • possible duplicate of [Configuring sudo to work without password](http://serverfault.com/questions/133529/configuring-sudo-to-work-without-password) – mailq Oct 22 '11 at 10:38
  • 1
    I should tell you that you haven't set up VirtualBox correctly - it does not normally require root to run. – Kvisle Oct 22 '11 at 13:07
  • Kvisle is right, VirtualBox doesn't normally require root-access. But (at least on debian) virtualbox-users should normally belong to the vboxusers-group. – olemd Nov 09 '11 at 18:33

3 Answers3

7

You can still use sudo to run programs without having to type a password. You can do this by running the visudo command and adding a line in for VirtualBox:

sudo visudo

Add the following line to the file

yourusername ALL = NOPASSWD: /path/to/virtualbox

Then create a desktop shortcut to sudo /path/to/virtualbox and it should run as root without a password.

michaelx386
  • 266
  • 1
  • 3
1

if you make sure that executable is only accessible by the user you want it to run, then you could set the SetUser bit in permissions like:

chown root:root myexecfile
chmod u+s myexecfile

when you do that, the file will run with set-uid bit, ie its owners permissions, instead of the user who runs it. You could use chmod g+s myexecfile to same end, only set group but instead of user bit.

However, be very careful: if you leave this file in the open, it is an inherently insecure way. For instance, if you put it on your desktop, make sure your Desktop folders permissions are 700 (no access to anyone but you).

0

You should use gksudo for this purpose. It will allow you to run graphical programs as root, using a graphical authentication prompt. Making the binary setuid-root or removing password requirement for sudo will open you up to privilege escalation attacks.

bonsaiviking
  • 4,355
  • 16
  • 26