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

-p, --parents remove DIRECTORY and its ancestors; e.g., rmdir -p a/b/c' is similar tormdir a/b/c a/b a'

Yeah - I'm definitely not going to risk testing that out myself. ;)

share|improve this question
up vote 4 down vote accepted

It does precicely what it says: it attempts to remove all the directories in the path that you give to it.

If you give it an absolute path, it will attempt to remove all the way back to root, so make sure you give it a relative path.

share|improve this answer
Oh interesting - so there are concrete differences between absolute and relative paths. If it removes absolute paths, then will it also remove all of the descendants of each of its ancestors too? So if I gave it an absolute path, would it also remove /bin, /usr, /var, and /etc? – InquilineKea Oct 5 '11 at 20:01
Only if those directories are empty. rmdir will only remove empty directories. – James Sneeringer Oct 5 '11 at 20:18
@InquilineKea There isn't really anything special about using an absolute path, it's just going to treat root as one of the things you want to delete -- it's equivalent to running rmdir /a/b/c /a/b /a /. So even if /a/b/c actually existed, it would fail when it got to removing /, since other directories still exist (you'd get "Directory not empty") – Michael Mrozek Oct 5 '11 at 20:19

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.