Server Fault is a question and answer site for system and network administrators. 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

T would like to use the tar command in Linux to back up some files, but i would like to exclude a specific directory from the archive.

How can I do that?

share|improve this question
up vote 3 down vote accepted

so, lets back up the directory /directory and everything in it, but ignoring any files called IGNORE-ME.

tar -cf backup.tar /directory --exclude "IGNORE-ME"

If it wasn't snowing out, i'd probably point out that man tar is as good as RTFM (and google 'tar exclude file' is even faster).

share|improve this answer

You can also put all of the patterns in a file and use:

-X, --exclude-from=FILE
              exclude files matching patterns listed in FILE
share|improve this answer
much better answer than mine -well, far more practical assuming you want to mask more than the one file :) see, I read the man page, but obviously not all the way down to -X ;) – BuildTheRobots Jan 6 '10 at 20:22

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.