22 Votes

Linux: Mount Folder using own Name and Rights (not Root)

Question by Guest | Last update on 2022-12-03 | Created on 2018-01-31

I would like to include or mount a folder with my own user name and accordingly also with my own rights on Linux.

So far, I'm using the following mount command:

mount -t vboxsf hdir /home/me/Desktop/gdir

This mounts the external folder "hdir" (hostdir) on my desktop to the folder "gdir" (guestdir).

This works so far, but this leads to the fact that owner and group is set to "root". However, I would like to have my own username and my own group instead of "root". Is that possible?

ReplyPositiveNegative
2Best Answer2 Votes

You can pass your own user ID (UID) and group ID (GID) as an option to the mount command. Then you will be the owner of the mounted folder:

mount -t vboxsf -o uid=1000,gid=1000 hdir /home/me/Desktop/gdir

Here we added "-o uid=1000,gid=1000" to the command. The "-o" introduces the options, which are listed behind comma separated. The user ID (UID) is set to 1000 here, the group ID (GID) also to 1000.

The UID 1000 is automatically assigned to the first created user under Ubuntu. With the command id you can find out your own user ID from the terminal and insert it accordingly into the command (instead of 1000 if you have a differing ID).

You can also add the option "umask" with which you can restrict the access rights:

mount -t vboxsf -o uid=1000,gid=1000,umask=022 hdir /home/me/Desktop/gdir

With "umask=022" you set the rights to a maximum of 755 (777 - 022 = 755). If you want to define different permissions for folders and files you can use the options fmask and dmask instead of umask.

With "fmask=022,dmask=000" you set the rights to a maximum of 755 for files (f stands for files) and 777 for folders (d stands for directories). Leaving these options aside, will by default use 022 for FAT file systems and 000 for NTFS file systems.
Last update on 2022-12-03 | Created on 2018-01-31

ReplyPositive Negative
Reply

Related Topics

Rename File to its Folder Name

Tutorial | 0 Comments

VirtualBox: Change Date and Time

Tutorial | 10 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.