Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 am using Ubuntu on Virtual Box and I have a folder which is shared between the host (Windows) and the VM (Ubuntu). When I open any file in the share folder in Ubuntu, I can not change it as its owner is set to root.

How can I change the ownership to myself?

Here is the output of ls -l :

-rwxrwxrwx 1 root root 0 2012-10-05 19:17 BuildNotes.txt

The output of df is:

 m@m-Linux:~/Desktop/vbox_shared$ df
 Filesystem           1K-blocks      Used Available Use% Mounted on
 /dev/sda1             29640780  10209652  17925440  37% /
 none                    509032       260    508772   1% /dev
 none                    513252       168    513084   1% /dev/shm
 none                    513252        88    513164   1% /var/run
 none                    513252         0    513252   0% /var/lock
 none                    513252         0    513252   0% /lib/init/rw
 Ubuntu               214153212  31893804 182259408  15% /media/sf_Ubuntu
 /dev/sr0                 53914     53914         0 100% /media/VBOXADDITIONS_4.2.0_80737
 Ubuntu               214153212  31893804 182259408  15% /home/m/Desktop/vbox_shared

The options in VM is automount and the readoly is not checked.

Tried to use /media/sf_Ubuntu, but getting permission error:

m@m-Linux:/media$ ls -l 
total 10
drwxrwx--- 1 root vboxsf 4096 2012-10-23 15:35 sf_Ubuntu
drwxrwx--- 2 root vboxsf 4096 2012-10-21 23:41 sf_vbox_shared
dr-xr-xr-x 6 m    m      2048 2012-09-13 07:19 VBOXADDITIONS_4.2.0_80737
m@m-Linux:/media$ cd sf_Ubuntu/
bash: cd: sf_Ubuntu/: Permission denied
m@m-Linux:/media$ cd sf_vbox_shared/
bash: cd: sf_vbox_shared/: Permission denied

Please note that I am in the group vboxsf:

m@m-Linux:~$ id
uid=1000(m) gid=1000(m) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(m),1001(vboxsf)
share|improve this question
How did you mount the shared folder? Are you letting it be automounted by the VirtualBox guest utils (i.e. /media/sf_something) or did you mount it manually using the mount command? – EightBitTony Oct 23 '12 at 14:45
Also, can you describe how you have configured the share under VirtualBox in Windows? There are three options for the share, read only, automount and permanent, which options have you ticked. – EightBitTony Oct 23 '12 at 14:48
Please post updates to your question - not as comments. Please include the output of df and the command you used to manually mount the filesystem. – EightBitTony Oct 23 '12 at 14:53
Thank you - you will see there is a /media/sf_Ubuntu filesystem. That's your shared folder, you don't need to manually mount it. I suggest you umount the /home/m/Desktop thing, and just use /media/sf_Ubuntu which works as per my answer below. – EightBitTony Oct 23 '12 at 14:57
@Tony: I can not access this folder. Please see my original question which I add more information – user654019 Oct 23 '12 at 15:26
up vote 63 down vote accepted

The regular way of getting access to the files now, is to allow VirtualBox to automount the shared folder (which will make it show up under /media/sf_directory_name) and then to add your regular Ubuntu user to the vboxsf group.

usermod -aG vboxsf <youruser>

By default, without manual action, the mounts look like this,

drwxrwx--- 1 root vboxsf 40960 Oct 23 10:42 sf_<name>

so the vboxsf group has full access. By adding your user to that group, you gain full access. So you wouldn't worry about changing their permissions (which don't make sense on the Windows host), you just give yourself access.

In this specific case, this is the automounted Shared Folder,

Ubuntu               214153212  31893804 182259408  15% /media/sf_Ubuntu

and it is that directory that should be used to access to the Shared Folder, by putting the local user into the vboxsf group. If you want a 'better' link under your user's home directory, you could always create a symbolic link.

ln -s /media/sf_Ubuntu /home/m/Desktop/vbox_shared

If you manually mount the shared folder, then you need to use the relevant options on the mount command to set the folder with the right ownership (i.e. the gid, uid and umask options to mount). This is because the Host OS doesn't support the same permission system as Linux, so VirtualBox has no way of knowing who should own the files.

However, I strongly recommend just configuring the shared folder to be auto-mounted (it's a setting on the Shared Folder configuration in VirtualBox itself).

For the avoidance of doubt, I do not believe you can change permissions normally anyway, on that filesystem if it's mounted in the regular way,

tony@jabba:/media/sf_name$ ls -l tst.txt
-rwxrwx--- 1 root vboxsf 2283 Apr  4  2012 tst.txt
tony@jabba:/media/sf_name$ sudo chown tony tst.txt
[sudo] password for tony: 
tony@jabba:/media/sf_name$ ls -l tst.txt
-rwxrwx--- 1 root vboxsf 2283 Apr  4  2012 tst.txt
share|improve this answer
When I tried this, I got the message that user is lready in group, but when I am trying to change a file on share folder, I am getting error when I want to save it. The error is: Could not save the file /home/m/Desktop/vbox_shared/test.tst Unexpected error: error renaming temporary file: Text file busy. – user654019 Oct 23 '12 at 14:40
That's a different problem, potentially not due to permissions. Can you create a new file, or modify a different file. Hang on - /home/m/Desktop/vbox_shared? Have you manually mounted the shared folder? That's not the default path. – EightBitTony Oct 23 '12 at 14:41
Checking system, I found that I only have permission to create or delete files and not read/write permision. How can I give it to myself? – user654019 Oct 23 '12 at 14:43
Please add the output from ls -l of the relevant files to your question. – EightBitTony Oct 23 '12 at 14:44
@Tony:yes I manually mount it. How can I automount it?I checked the automount in VM setting (also giving full access) – user654019 Oct 23 '12 at 14:47

I had the same problem and I solved installing the latest version of VirtualBox Guest Additions; in my case was upgrading from 4.3.8 to 4.3.10.

When installation was finished, the /media/sf_name folder had no more "root" as group owner, but "vboxsf" as correct.

share|improve this answer

I just have had the same problem with my Win-Ubuntu shared folder, and the way I solved it was adding my user into the vboxsf group, editing the /etc/group file. Hope this works for you. Down here you can find a short scheme of how I edited the file

(edit /etc/group)
vboxsf:x:999:openquake,luisa   ##This is the line I add my user


share|improve this answer
You should never edit /etc/group directly, use the appropriate tools for this job (in this case usermod -aG <group> <user>). – Raim Nov 5 '15 at 0:18
The main, if not only, reason why this is recommended is because if you accidentally make a mistake manually updating a file like /etc/group, it can invalidate the DB and essentially lock you out. – Spencer Williams Nov 12 '15 at 20:07

Have you tried sudo?

$sudo chown username filename
share|improve this answer
I don't believe this works on VirtualBox shared folders. – EightBitTony Oct 23 '12 at 12:43
sudo works everywhere! :P link – Extn3389 Oct 23 '12 at 12:46
I'm not sure if you're serious, but I'll humour you. The mounted shared folder is a vboxfs type filesystem, it does not honour chown's. – EightBitTony Oct 23 '12 at 12:47
I am sorry I just thought this might work. – Extn3389 Oct 23 '12 at 13:18
Yes, but it did not change the owner. After running tis command in a terminal for a file, and then looking at the file owner, it still belongs to root. – user654019 Oct 23 '12 at 13:41

Virtual box additions have to be installed again after you upgrade your guest system. The problem, I think, is when you upgrading some components in ubuntu, some components changed, after installing vb-additions, sf_forlder_name will be accessible. My problem solved by this way. Pisu's solution works.

share|improve this answer
In my experience virtual box guest additions only have to be upgraded when the host VirtualBox system is upgraded. Not when any software on the client changes. What software on the client did you upgrade to make this necessary? – Anthon May 18 '14 at 7:13
No, nicky is right. You have to re-install the Guest Additions if you update your guest OS kernel. – Spencer Williams Nov 12 '15 at 20:08
  • Unmount shares as root
  • Make required changes with chown and chmod
  • reboot and checkout the shares are with proper rights
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.