Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I copy some directory (dir) recursively with sudo in bash it copies just the first level of the dir hierarchy, but when used without sudo it copies the dir with all its subdirs, though commands in command-line have the difference only in the presence of sudo.

Why does this happen?

For example:

k@l:/$ tree
|  |
|  |__b
|     | 
|     |__1.htm   
k@l:/$ sudo cp -r /a/b /c/d
k@l:/$ cd /c
k@l:/c$ ls
k@l:/c$ cd d
bash: cd: /c/d: Permission denied
k@l:/c$ tree
|__d [error opening dir]

1 directory, 0 files
share|improve this question

migrated from stackoverflow.com Jul 26 '11 at 8:40

This question came from our site for professional and enthusiast programmers.

There are error messages on your listing. You perhaps want to learn their meaning first. –  n.m. Jul 26 '11 at 5:11

1 Answer 1

up vote 2 down vote accepted

Maybe /c/d had permissions 700 with a different owner. Try sudo chmod -R 755 /c/d.

share|improve this answer
+1: Or you could try 'sudo chown -R me /c/d'. –  Jonathan Leffler Jul 26 '11 at 6:50
Yup, that'd work too. –  jman Jul 26 '11 at 7:02

Your Answer


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.