0

I am user_a and I have a password for user_b, so I can use su user_b to do things as user_b.

I want to copy a file from user_a to user_b.

I don't want other users besides user_a and user_b to see the file, and I don't have root on the machine. So the usual trick of moving the file to /tmp is not acceptable.

1

You can use back to back tar to do the copy. For example

 tar cf - file1 file2 dir1/file3 | su user_b tar -C ~user_b/somewhere -xf -

This will create ~user_b/somewhere/file1 as a copy of file1. ~user_b/somewhere has to exist first. There are some limitations on the tar format, but you are unlikely to hit them.

If it is just a single file then

 su - user_b bash -c 'cat > ~user_b/file1' < file1

followed by adjusting the permissions might be less trouble.

| improve this answer | |

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