copying files from one user to another in a single machine

Solution 1:

Assuming that you have sudo privileges the following command will do.

sudo cp /home/USER1/FNAME /home/USER2/FNAME && sudo chown USER2:USER2 /home/USER2/FNAME

Will copy the file from USER1 to USER2, and then change the owner of the copy in /home/USER2 to USER2

If you do not have sudo privileges, then the two users will need to ensure that you have read permissions on the USER1 directory, and write access on the USER2 directory. If you have these accesses, you can enter the command:

cp /home/USER1/FNAME /home/USER2/FNAME

This will copy the file in question, but USER2 may not be able to manipulate the file until they have appropriate permissions.

Solution 2:

As USER1:

cp [filename] /tmp
chmod 777 /tmp/[filename]

As USER2:

cp /tmp/[filename] .

As USER1:

rm /tmp/[filename]

Solution 3:

if you dont have sudo privileges but you can login with the two users then you can use scp with localhost :

scp file1 user2@localhost:/home/user2/