Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to execute a command as if I am my normal user, but I want to have root certain permissions. In particular, I have created a phyiscal VirtualBox drive that I want to use as a normal user.

I can sudo to VirtualBox, but that gives an unconfigured VirtualBox. On the other hand, if I want to add my raw image (create by VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda as per documentation) as the drive for a virtual machine it gives me a permission error.

So basically I have this: Multiple virtual machines, all with virtual drives in vdi or vmdk images. Now I want to have another VM, but this time with a phyiscal drive and I need my normal user to have permissions to do this (possibly with entering my passwort to give it root access, my main concern is that it should execute as a specific user and not as root, although it has root permissions).

Is this at all possible? If so, how?

share|improve this question
up vote 3 down vote accepted

So far most modern systems use udev, and changing any permissions/owners under /dev are effective until host system restart.

I suggest following actions:

  1. ls -l /dev/sda

    On my system it looks like this:

    brw-rw----   1 root   disk        8,   0 янв.  11 13:43 sda

    so disk group has read write access

  2. sudo gpasswd -a youruser disk

    We just added youruser to group disk

  3. Most important step: relogin youruser or reboot host system, because until then youruser disk group membership will not be effective

share|improve this answer

You have to change the permissions on /dev/sda so that the VirtualBox user can read and write to it.


share|improve this answer

I reckon you can probably solve this problem with file permissions rather than sudo ??

Might be worth checking that your user is in the vboxusers group:

sudo usermod -a -G vboxusers username

Failing that try changing the permissions of the file in question:

chmod 760 /path/to/file.vmdk

should create permissions like the following:

-rwxrw---- 1 user group 0 Jan 23 10:35 /path/to/file.vmdk

where rwx = read/write/execute for the user

where rw- = read/write for the group

where --- = no permissions for other users

You can run the following on the directory to ensure the user has access also:

chmod 770 /path/to/

drwxrwx--- 2 user group 4096 Jan 23 10:40 /path/to/

( more info on chmod here: )

OR if the virtual drive is only ever going to be used by the "user" you mentioned and no other user, then you can simply chown the file to that user, giving them full access to the file when logged in as that user. (and possibly copy the file into their home directory for the sake of being tidy ? optional.)

chown username /path/to/file.vmdk

Still requires the user to have permissions to that directory in order for it to access the file.

( more info on chown here: )

share|improve this answer

You could try this:

runuser -l lambda -c 'ls -la'

Where ls -la is the command (example) that you want to execute as non-root and lambda is a normal user created like any classic normal Linux user account.

You are a root who wants to use a normal account. As a root you don't need to give the normal account password.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .