tar: Removing leading `/’ from member names


Here is how to remove the message:  tar: Removing leading `/’ from member names when tarring files.

This is your normal command which will produce a tar file but give you the message: tar: Removing leading `/’ from member names

# create a tar file of the directory /etc called foo.tar
tar -tvf etc.tar /etc # TAR FILE
# create a tar.gz file of the directory /etc called foo.tar.gz
tar -vczf etc.tar.gz /etc # TAR GZIP FILE
# create a tar.bz2 file of the directory /etc called foo.tar.bz2
tar -cjf etc.tar.bz2 /etc # TAR BZIP FILE

This is the option in tar you use to prevent the message
# remove the message like with the -C option
tar -tvf etc.tar -C / etc # TAR FILE WITHOUT MESSAGE
tar -vczf etc.tar.gz -C / etc # TAR GZIP FILE WITHOUT MESSAGE
tar -cjf etc.tar.bz2 -C / etc # TAR BZIP FILE WITHOUT MESSAGE

  • C: When this option is specified, `tar’ will change its current directory to DIR before performing any operations. When this option used during archive creation,  it is order sensitive.

If you would like to list the contents of the newly created tar.bz2 file run this command:
tar -tvf etc.tar # LIST THE CONTENTS OF A TAR FILE
tar -ztvf etc.tar.gz # LIST THE CONTENTS OF A GZIP FILE
tar -jtvf etc.tar.bz2 # LIST THE CONTENTS OF A BZIP FILE

  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f filename: Use archive file called filename

For additional information on tar see the man pages.

2 thoughts on “tar: Removing leading `/’ from member names

  1. Pingback: TAPE BACKUP COMMAND - TAR for SLES11

  2. Brendan Skoreyko

    Based on what you have: “tar -cfz /dev/st0 /tape_test” you will need to change it to “tar -cfz /dev/st0/tape_test.tar /tape_test.” You have to specify the output tar file… I haven’t worked with tapes for a couple years now and I don’t have one to test with. You could try taring the directory first and then do something like “mv /dev/st0” – this should move the file once you have created the compressed version, so write a short script.

    1) compress directory you want backed up
    2) move or copy the compressed directory to your tape drive

    Post back and let me know is you have any success!

Leave a Reply

Your email address will not be published. Required fields are marked *