bsdtar command – Read and write tape archive files

FreeBSD uses a version of tar written from scratch to replace the older GNU tar, called bsdtar. bsdtar can behave completely consistently with GNU tar, and can also behave in strict accordance with POSIX tar. If you’re at all concerned about the differences between GNU tar, POSIX tar, and bsdtar, read man tar(1) for all the gory details. bsdtar is actually built on libarchive(3), a library that developers use to add support for backup archives into other programs. tar(1) can be dumb. If your filesystem is corrupt in any way, tar will back up what it thinks you asked for. It will then happily restore files that were damaged during the original backup, overwriting working-but-incorrect files with not-working-and-still-incorrect versions. These sorts of problems rarely happen, but tend to be unforgettable when they do.

Syntax:

$ bsdtar [parameter]

Command parameters:

  • -c – Create an archive
  • -f archive-filename – The name of the archive file
  • -t – List the contents of the file
  • -x – Extract the contents of the archive

Examples of bsdtar Command

1. List the file name and content of the archive:

# bsdtar -tf archive-filename

2. Extract the contents of the archive:

# bsdtar -xf archive-filename

3. Create an archive:

# bsdtar -cf archive-filename

4. Using tar, we can create an archive with -c, and we can compress it with gzip and -z. You also need to provide -f to save the resulting archive to a file. Otherwise, the archive will be outputted to Terminal.

# bsdtar -czf archive-filename.tar.gz archive-filename
Related Post