Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems very strange to me. I'm running kernel and ran:

~]$ cp -r /proc/ here
~]$ rm -rf here

I get some permission denies when copying as expected and I eventually hit Control-C. I get Permission denied on a lot of files when trying to remove the new directory and files.

As a note, I found this weird behavior because a friend sent me a .tgz of a snapshot of his /proc dir. I extracted the directory and when I was finished looking through it I had the same problem.

rm -rf as root does work.

lsattr shows the e attribute (which is what all of my files/directories show).

share|improve this question
I've generalized the title of your question a little because the core issue isn't about /proc. By the way, it's a bit late for this time, but if you figure out the answer after posting the question, it's fine to answer it yourself, and leave it up for other people who might run into a similar problem. – Gilles Mar 2 '11 at 23:55
up vote 13 down vote accepted

If there is a non-empty directory where you don't have write permission, you can't remove its contents.

$ mkdir foo
$ touch foo/bar
$ chmod a-w foo
$ rm -rf foo
rm: cannot remove `foo/bar': Permission denied

The reason is that rm is bound by permissions like any other command, and permission to remove bar requires write permission on foo. This doesn't apply when you run rm as root because root always has the permission to remove a file.

To make the directory tree deletable, make all the directories in it writable (the permissions of regular files don't matter when it comes to deletion with rm -f). You can use either of these commands:

chmod -R u+w here        # slow if you have a lot of regular files
find here -type d -exec chmod u+w {} +
share|improve this answer

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.