Transferring Data from one User Account to Another

Discussion in 'macOS' started by j0ester, Dec 21, 2012.

  1. j0ester macrumors member

    Jun 14, 2012
    Is it possible to transfer several documents and folders from one Account to another account? I was told no, because those files and folders permissions is set to the other Account. If this is so, how do we remove those permissions and give the other Account those?
  2. switon, Dec 21, 2012
    Last edited: Dec 21, 2012

    switon macrumors 6502a

    Sep 10, 2012
    RE: scp, chown, chmod, chflags, etc....

    Hi j0ester,

    Yes, it is possible to transfer documents between two accounts, assuming you have administrator privileges or know the passwords of both accounts.

    Let's say that you don't have administrator privileges but know the account passwords, then I would suggest using "scp" to perform the transfer. The reason for this is because it has the privilege to copy the document and will also change the ownership and group for you on the file. For instance, from the account of user1, do the following (note that the ~ is interpreted by the bash shell as the login, or home, directory):

    cd ~
    scp user2@host.machine/Users/user2/Document .
    To execute this "scp" command user1 needs to know user2's password.

    This "scp" command will make of copy of user2's file ~/Document and place the copy into user1's login directory as file ~/Document. The permissions are preserved but the ownership and group of the Document file are changed to user1:user1group. You can, of course, change the directories and files that are copied via this command.

    Let's say that you have administrator privileges, then you can do a "sudo cp":

    cd ~
    sudo cp /Users/user2/Document ~/
    and this will copy user2's ~/Document file to user1's home folder. Let's say that you wish to change the ownership, group, permissions, ACLs on a file, then use the "chown" and "chmod" commands. For instance, the following commands will change the ownerships and permissions on a file:

    cd ~
    sudo chown user1:user1group Document
    sudo chmod ugo+r Document
    sudo chmod u+w Document
    sudo chmod go-w Document
    where the "chown" command changes the owner and group on Document to user1 and user1group. The "ugo+r" option to "chmod" adds the Read permission for the User (owner), Group, and Other (everyone else) to Document. The "u+w" option adds the Write permission for the User, and the "go-w" deletes the Write permission for the Group and for Other (everyone else). [If you own the file, then you do not have to use "sudo" to change the permissions on the file.]

    The "chmod" command also can be used to specify the ACLs for files. See the manpage documentation for details, "man chown", "man chmod", "man ls", "man chflags", "man scp", and "man ssh".

    Edit: You can also transfer a folder and its subdirectories using these methods. And the "-R" option to the "chown" and "chmod" commands will recursive apply the ownership, group, and permissions to a folder and its subdirectories.


    P.S. The "ditto" command, with administrator privileges, will perform a copy of directory trees attempting to maintain all ownerships and permissions. The nice thing about "ditto" is that it does not fail when encountering an error, rather it tries its best, logs the error, and then continues with the copy. The "rsync" command will also perform the copying of files.

Share This Page