Copying file to other drive converts it to root

If I copy a file from my home folder to a shared NTFS drive, the copy is owned by root. I’m not using sudo or anything. I get the same result if I use Nemo to copy.
Is it something wrong with he way the drive is mounted?

 ~
touch testfile
 ~
cp testfile /mnt/M/
 ~
ls -l testfile
-rw-r--r-- 1 me me 0 Mar 23 14:18 testfile
 ~
ls -l /mnt/M/testfile
-rwxrwxrwx 1 root root 0 Mar 23 14:19 /mnt/M/testfile

This is in my fstab:

 LABEL=m2dat                               /mnt/M         ntfs    user,noatime 0 0

The Linux concepts of ownership and permissions don’t apply to NTFS. This means that chown and chmod won’t work for changing the ownership or permissions for NTFS.

If I am not mistaken, an NTFS partition will mount with owner:group as root but with permissions 777 as can be shown by

That means everybody can read-write-execute any files.

However you could set Linux compatible permissions via fstab:

https://wiki.archlinux.org/title/NTFS-3G#Linux_compatible_permissions

4 Likes

So permissions are not part of the file itself, they’re managed by the file system? makes sense, I just never thought about it.

Interestingly, if I copy the file back to its original location, it gets assigned -rwxr-xr-x me me, which sounds reasonable if it’s lost the original permission info.

i’ve also found that wrapping the file in an archive seems to preserve the permissions of the files inside somehow (just tried with 7z a).

I’ll look into your link for Windows sharing, that sounds useful.

Thank you.

1 Like

You can use options uid, gid, dmask and fmask in /etc/fstab for the ntfs filesystem.
See: man ntfs-3g.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.