Change owner of internal hard drive partition from root to user
Solution 1
Did you try
sudo chown user:user
For example sudo chown cyrex:cyrex
(User:Group)
if the partition is called party, your user is called cyrex and it is in /media
just do for example:
sudo chown cyrex:cyrex /media/cyrex/party -R
(The R is for recursive so it affects all directory/files and subdirectory.
As noted, the partition is NTFS so if is automatically mounted you need to make sure that the user that has permission is you. To do this follow this steps:
-
Go to console (
gnome-terminal
) -
Type
id -u
. This should give you the user id you have which you will insert into fstab. -
Open fstab
sudo /etc/fstab
and search for the line that is mounting the ntfs partition. -
Assuming is something like this:
UUID=1234532123 /media/amntfs ntfs defaults 0 0
Add to it the umask, uid and gid masks like this
UUID=1234532123 /media/amntfs ntfs defaults,umask=007,uid=1000,gid=1000 0 0
Save the file and just reboot or remount the unit.
Here:
- The uid is your User ID. The one you got from
id -u
. - The gid is you Group ID. Normally the same as
id -u
but you can check it withid -g
. - The umask is like chown but reversed.
See How do I use 'chmod' on an NTFS (or FAT32) partition? on more about using chmod
/chown
on NTFS filesystems.
NTFS and POSIX Compatibility
It is correct to think that NTFS is not 100% POSIX compatible. But it is also true that NTFS is POSIX conformant, meaning it is similar but not exact to the POSIX that is used in Linux. As you read my answer you find 2 things here:
- I target changing permissions on the NTFS files
- I target changing permission at the mounting level or while mounting in the fstab.
For the mounting level it is pretty straightforward there. It is in the file permission as described above that, if analyzed, it really does not make sense and should not be working. But the thing is a bit more complicated. So here is the rundown as a technician on Windows in the 90s and a Linux user since 2001.
When you mount an NTFS filesystem (at least on Ubuntu), NTFS-3G takes care of the proper mounting for it and even offers mapping capabilities to make sure that the instructions in regards to permissions are mapped from Linux to the NTFS filesystem correctly. Meaning, if I do chmod or chown, they would work.
This is only half of the answer. The other is that NTFS is conformant with POSIX or you could say "compatible" to a certain degree, but as far as I can recall, it is for version 1 of POSIX, I think called POSIX.1 from the 1990s and only for a certain subset of the windows subsystem.
So, between NTFS-3G and the "compatibility" of NTFS with POSIX, you are in fact able to use chmod on the NTFS files and folders.
I can not say anything about newer versions of NTFS on Windows 8.1, 10, 11 or future versions about how they are POSIX compatible, but I can talk about the current one and experience I have about the background for NTFS, POSIX and how they relate in a very weird way when talking about Windows.
Minor Update: starting on Kernel 5.15 (Oct 31, 2021), there is a new NTFS implementation as read HERE where it shows enhancements on how we deal with NTFS.
Solution 2
All my NTFS partitions are owned by root, yet I can access them fine as user. It's a matter of mount options rather than ownership and file permissions (remember, it's a NTFS partition - you can't change any permissions there).
In my /etc/fstab
the partitions are included as follows:
UUID=AB84274F84211B98 /media/WIN7 ntfs defaults 0 0
UUID=CDBAF39E13A2AC2D /media/DATA ntfs defaults 0 0
UUID=EFA980B33BA33DF5 /media/MEDIA ntfs defaults 0 0
where defaults
are default mount options that already should do what you want to do.
To find the UUIDs, run sudo blkid
.
See also: How do I use 'chmod' on an NTFS (or FAT32) partition?
Solution 3
I was having a hard time solving the problem and this solution worked for me
- install physical storage device manger:sudo apt-get install pysdm
- open storage device manger:sudo pysdm
- choose your required drives
- press assisst:
- uncheck open as read only
- check owner user of file systemand write your username:remon
- press ok
- press apply
- umount Drive
- mount it
Note: if you can't change files to binary executables, go to special files and check permit execution of files as binaries, and go to step 7
Solution 4
The easiest is to in terminal open file manager as sudo
sudo nemo
or sudo nautilus
or what ever file manager linux is using, then right click on partition and add permisions
Related videos on Youtube
Charles Kane
I'm looking for clarity, simplicity. As I'm a user not an expert I prefer a readily available GUI (I'll use ppas but prefer the software centre). Similarly I will use terminal but prefer a brief explanation of each command I am executing, both so I can learn and keep an eye on what I'm doing. Referencing some Ubuntu documentation is always great, because, lets face it, the documentation can be pretty hard to find.
Updated on September 18, 2022Comments
-
Charles Kane over 1 year
I have a number of drives internal and external. Some are partitioned. Most mount automatically at boot (all did at one point).
One partition is owned by root and therefore does not mount automatically. I know how to mount it as root.
I do not know how to take ownership of that partition as user X. I have tried changing permissions using the gui in Nautilus as root. They are not accepted and immediately revert.
The partition is NTFS. The other parition on that drive is owned by me as user and mounts automatically
-
mvario almost 13 yearstry sudo chmod a+rwx /yourpartition
-
enzotib almost 13 yearsif they mount automatically at boot time, it means you modified your
/etc/fstab
, so edit your question to show the content of this file.
-
-
enzotib almost 13 years
chown
do not works on NTFS partitions. -
Luis Alvarado almost 13 yearsLol. Did not read that small, tiny, elusive 4 letter word. Added content for NTFS permission.
-
enzotib almost 13 yearsIt was strange that a 5k user like you do such a mistake :). Regarding
id user | cut ...
I suggestid -u
. -
Luis Alvarado almost 13 yearsCorrect much better. Anybody can make a mistake so do not mind the points... am still human... for now (Evil eyes). Thanks for pointing it out.
-
Francesco Borzi over 5 yearsThis worked for me, thanks a lot. The only note: I had to restart (just unmounting and mouting the partition again didn't work).
-
Raknos13 almost 4 yearsThe provided link at the end worked for me.
-
xpt over 2 yearsHi Luis, would you take a look at this newest answer please? askubuntu.com/q/1375775. Basically the answer disagrees with all that I found, including this one. I want to change the ownership of files on mounted ntfs to me but he strongly disagree and he seems to be pretty confident in his belief, and I'm wondering if it is really so. thx.
-
Luis Alvarado over 2 years@xpt I have updated my answer to reflect about that. I also recommend, based on your answer in the other post to send me an email at [email protected] so I can help you in a more direct way because you do have a uncommon case there.
-
xpt over 2 yearsOh thx for the update Luis. For my question in the other post, I've already sorted it out, before he went on defending his wrong answer. My concern was that it is the newest answer to the topic, so search engines will direct people there, which will confuse people more than it helps. I tried to delete it, and found that it wasn't allowed.
-
alchemy about 2 yearsWhat would the
permissions
argument in fstab be for then? askubuntu.com/q/92863/795299 -
Marcelo Scofano Diniz about 2 yearsEasiest and fastest...