I want to copy a file/folder from another user's home directory to my home directory in Linux.

I cannot access his directory, because it says permission denied. I'm 100% sure that a file can be copied from another user's home directory, because someone has showed me how, but I have forgotten.

This is what I'm currently doing:

[my_user@server1 users]$ cp /users/other_user/file /users/my_user
cp: cannot stat `/users/other_user/file': Permission denied
[my_user@server1 users]$ mv /users/other_user/file /users/my_user
mv: cannot stat `/users/other_user/file': Permission denied

How can I do it?

  • use sudo before cp, you'll be asked for your password, if you have access to sudo, you'll be able to do that cp. – alexus Jun 25 '15 at 19:39
  • See Copy file from user to another in Linux (on U&L) for more answers (using sudo). – Scott Apr 4 '18 at 4:28

If you don't have permission, then you can't copy the file.

The only ways around that are by elevating your permissions, for example by becoming root or the other user. You could try 'scp':

scp other_user@localhost:file .

or copy the file as root (but then be aware that the destination file is owned by root).

| improve this answer | |
  • What if I wanted to move the file? Copying and then removing is inefficient. Is there a workaround? – becko Feb 19 '15 at 18:52

The other user either needs to give you read access (and execute access on the directories).

You can most repeatably do this by creating a group and having both of you join it, then granting appropriate access to the group.

You can also copy the file as root, if it's one-time, then use chown/chgrp to reset the permissions to your user.

(It may also be easier to request the other user copy the file into a folder you set up.)

| improve this answer | |

please check your access with

ls -ld /users/other_user
ls -l /users/other_user/file

and post the output.

btw how come you have a users folder? usually the path for user profiles is /home/username, or use the special path syntax ~username/file

do you have root access to the machine? then you could copy the file ignoring the access rights.

| improve this answer | |
  • I tried it, it says: Permission denied. I don't know why it is "users" – alwbtc Nov 3 '11 at 14:37

If you have root login,

cp ~FIRSTUSER/file ~NEWUSER/newlocation

To be sure that the user has full access to file, as root,

chown FIRSTUSER ~NEWUSER/newlocation

| improve this answer | |

Use this general syntax:

sudo cp -r /Path-A /Path-B

For example: I have one directory called "DATA" on my desktop i.e. /home/DINESH/Deskop/DATA. You want to copy it to your desktop at /home/SURESH/Desktop/. You would use this command:

sudo cp -r /home/DINESH/Deskop/DATA /home/SURESH/Desktop/
| improve this answer | |

You have to go to the A user's account since it won't allow B user to create a folder on other A user's home folder, then you have to do:

sudo cp -r /home/A/MyDirectory /home/B

Hope this helps someone in need

| improve this answer | |
  • 1
    I don't understand what you're trying to say, here. Who are the "A user" and "B user"? What do you mean by "go to the A user's account"? How does using sudo achieve that? – David Richerby Jun 25 '15 at 21:11

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.