0

I currently have Ubuntu installed on one partition and my personal files (Pictures, Documents, etc.) on a second partition. I would like to install KDE Neon in the partition containing Ubuntu, while keeping the personal files partition.

I have yet to install Neon, but I have used a bootable USB.

The problem I've run into is that I don't know how to transfer ownership of files from an account on one installation to an account on another. If I were transferring files between accounts on the same OS, I would just use chown and be done with it, but I don't know how to do that across OSes.

I realize that I could set the permissions so that others have read access and then copy all of my files using the Neon account, but that would take hours due to how many files I have. I would rather use chown or something similar.

  • There is no such thing as files owned by a single OS. Files are just files no matter where they are. Please elaborate more. Do you need help finding and mounting the partition Ubuntu is on? – Christer Oct 6 '19 at 20:08
  • @Christer What I mean is, in Ubuntu, when I right click a file, select properties, and then select permissions, it says that the owner is me. When I boot into KDE Neon and do the same, it says that the owner can view and modify contents and that only the owner can change permissions. I will update the question with more info. – Ian Oct 6 '19 at 20:37
  • Ok, so what is stopping you from just using chown to change owner? Can't you just use sudo to avoid any permission issues? – Christer Oct 6 '19 at 20:53
3

I don't know how to transfer ownership of files from an account on one installation to an account on another.

Files are not owned by a username, they are owned by a UID. The mapping between username and UID is usually managed in the users database file /etc/passwd. Here's an example snippet

root:x:0:0:root:/root:/bin/bash
tom:x:1000:1000:Tom Pearce,,,:/home/tom:/bin/bash
bill:x:1001:1001:Bill Brewer,,,:/home/bill:/bin/bash
jan:x:1002:1002:Jan Stewer,,,:/home/jan:/bin/bash
peter:x:1003:1003:Peter Gurney,,,:/home/peter:/bin/bash

When you run ls -l the UID/GID owners for each file are translated using this database to the corresponding names. You can see the actual names with ls -ln.

So, to "transfer" ownership of files you have a couple of choices

  1. Make sure that the mapping of name to UID/GID is the same on both systems. No chown/chgrp is required in this instance because the files ownerships are mapped to the same set of names on both systems.

  2. Find out the original UID/GID and the target UID/GID and change every affected file one by one. This isn't quite as simple as it sounds because you have to be careful not to change a file to a UID/GID pair that will then later be changed once again. Typically, you would chown/chgrp each file to a temporary range of UIDs that isn't used anywhere on either system, and then change them from that set to the actual set.

    # Example to change file UIDs from 1000 to 1010
    find / -mount -user 1000 -exec chown 61010 {} +
    
    # Later, when you've moved all the file ownwerships out of the 1xxx range
    find / -mount -user 61010 -exec chown 1010 {} +
    
|improve this answer|||||
  • 1
    The first option you mentioned worked. The UID mapping was the same on each system and I didn't need to alter any permissions. Thank you. – Ian Oct 10 '19 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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