ZNHOO Whatever you are, be a good one!


"tar" stands for tape archive. It is an archiving file format.

List archive

~ $ tar -tvf hongkan.tar.xz

Create archive

~ $ tar -cJpvf hongkan.tar.xz hongkan/
  1. c: create tar file;
  2. J: compress the tar file with xz;

    Alternatives are: z for gzip, j for bzip2.

  3. p: extract information about file permissions;
  4. v: verbosely list files processed;
  5. f: archive file name.

Encrypt/sign archive

~ $ gpg --recipient you@email.com --sign --encrypt hongkan.tar.xz
~ $ gpg --output hongkan.tar.xz --decrypt hongkan.tar.xz.gpg

Extract archive

~ $ tar -tvf hongkan.tar.xz
~ $ tar -xJpvf hongkan.tar.xz [hongkan/test.md]

Update archive

# edit hongkan/test.md
~ $ unxz hongkan.tar.xz
~ $ tar --delete -vf hongkan.tar hongkan/test.md
~ $ tar -rpvf hongkan.tar hongkan/test.md
~ $ xz hongkan.tar
  1. r: append files to the end of an archive.

    There is no real way to replace an existing file with the same name. Even the -u --update parameter does not help.

    We must first --delete and then -r --append the file to archive.

  2. Cannot update compressed archives. Decompress tar first.