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.