Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a directory ~/c9/support/npm that is owned by my account. I have a target directory /mnt/ws/users/jan/npm that doesn't exist yet, but /users/jan is owned by usr_jan. Now I want to copy the folder to it's new location and I do:

sudo -Hu usr_jan cp -r ~/c9/support/npm /mnt/ws/users/jan/npm

Now it throws:

cp: cannot access /home/cloud9/c9/support/npm

Is it like prohibited to access data from someone else's home folder, even with sudo?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Of course, "sudo -Hu usr_jan" will do everything as that user, with their home directory, and not root. Use "sudo cp -pr /home/cloud9/c9/support/npm /mnt/ws/users/jan/" if you want to keep permissions from the source directory. cp -p keeps ownership/permissions if run by root.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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