0
ls -al /media/victor/Backup/ 

Output:

 insgesamt 25 drwxrwxrwx 1 root root 12288 19. Aug 13:49 . drwxr-x---+ 3 root root 4096 19. Aug 12:27 .. drwxrwxrwx 1 root root 0 19. Aug 10:43 DATA -rwxrwxrwx 2 root root 56 18. Jul 2020 .dropbox.device drwxrwxrwx 1 root root 4096 19. Aug 20:17 harddrive drwxrwxrwx 1 root root 0 19. Aug 13:24 'TEST LOCAL2' drwxrwxrwx 1 root root 0 19. Aug 13:19 .Trash-0 drwxrwxrwx 1 root root 0 19. Aug 12:56 .Trash-1000 drwxrwxrwx 1 root root 4096 18. Aug 22:55 'Vor 08.2025' 

I run sudo chown -R victor:victor /media/victor/Backup afterwards ls -al /media/victor/Backup/ and have the same output

 insgesamt 25 drwxrwxrwx 1 root root 12288 19. Aug 13:49 . drwxr-x---+ 3 root root 4096 19. Aug 12:27 .. drwxrwxrwx 1 root root 0 19. Aug 10:43 DATA -rwxrwxrwx 2 root root 56 18. Jul 2020 .dropbox.device drwxrwxrwx 1 root root 4096 19. Aug 20:17 harddrive drwxrwxrwx 1 root root 0 19. Aug 13:24 'TEST LOCAL2' drwxrwxrwx 1 root root 0 19. Aug 13:19 .Trash-0 drwxrwxrwx 1 root root 0 19. Aug 12:56 .Trash-1000 drwxrwxrwx 1 root root 4096 18. Aug 22:55 'Vor 08.2025' 

I mounted the harddrive with the user ownership:

ls -al /dev/sda2 brwxrwxrwx 1 victor victor 8, 2 19. Aug 21:06 /dev/sda2 

Is it possible to change the ownership of the files?

EDIT: Finally I did not need to change the ownership. The permission issues of writing files in the external hard drive which is because it was mounted in the fstab file as a type ntfs. After changing the mount type to ntf-3g, I was able to modify the data in the external hard drive as a standard user.

1
  • AFAIK, NTFS does not support permission/ownership like you'd want . Commented Aug 19 at 19:56

2 Answers 2

6

NTFS stores file ownership in the form of Windows security IDs (SIDs for short). There is a standard fixed SID for "Administrator", which is treated as equivalent to the root user. But in order for user victor to own any files, you would need to supply a persistent mapping file that tells the non-Windows NTFS driver the SID the user victor is supposed to map to.

In Linux, when using the FUSE-based NTFS-3G driver, such a mapping file would typically be located at <root of the filesystem in question>/.NTFS-3G/UserMapping (i.e. /media/victor/Backup/.NTFS-3G/UserMapping in your case).

If you don't care about interoperability with other systems, you can also use the mount option permissions with the NTFS-3G driver to use an auto-generated mapping, which will be valid locally only: any other Windows system accessing that NTFS filesystem will see files generated by the Linux user victor as owned by Account Unknown, as the Windows system will not have a matching SID in its user database.

Likewise, any files generated on the filesystem using a Windows system will appear as owned by root, because that's the closest Unix-like equivalent to the Windows practice of "files with unknown owner won't be accessible by anyone until someone with the appropriate privileges takes ownership of them and assigns appropriate permissions."

The ownership of the /dev/sda2 device only tells the system who can or cannot mount that device. It has no impact on how the filesystem driver assigns file and directory ownerships within the mounted filesystem: that is dictated primarily by the filesystem metadata, assuming the filesystem has concepts compatible with Unix-like users, groups and permissions.

If the filesystem metadata is inadequate for the purpose (i.e there's no mapping available between filesystem-specific concepts and Unix-style users and groups, or the filesystem has no concept of file owners at all), then there are typically filesystem-type-specific mount options to assign a default owner and group to all files and directories for that filesystem. Such an assignment is local-only, and will not actually persist in the filesystem after unmounting.

If you use Linux's kernel-based ntfs3, you could try mounting the filesystem like this, running the commands as the user victor:

mkdir -p /media/victor/Backup mount -t ntfs3 -o uid=$(id -u victor),gid=$(id -g victor) /dev/sda2 /media/victor/Backup 

Or if you already know the user victor has UID/GID 1000, you could simplify the second command as:

mount -t ntfs3 -o uid=1000,gid=1000 /dev/sda2 /media/victor/Backup 
5

No, that can't be done. NTFS has no knowledge of Linux user names (or permissions, as it were).

Mounting w/ user/group is your only option.

1
  • 1
    I mean, NTFS has much richer notion of file ownership and privileges than standard UNIX permissions (better think POSIX ACLs on speed with support for delegated authentication of users), but it's not represented correctly (meaning: both ways) by the ntfs kernel driver. Linux is just not the best system to deal with NTFS file systems. Commented Aug 19 at 21:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.