How to use password protection with the Linux tar command?

How can I use password protection with the tar command in Linux? I'm new to Linux so please explain to me with simple usage.


As far as I know tar doesn't provide this service. You could use 7zip instead, which does offer encrypted archives.

What you can also do is use gpg in addition to tar:

tar cvJf myarchive.tar.xz myfiles
gpg -c myarchive.tar.xz.gpg

This will give you a password protected archive.


Run the output through pgp

tar .... | pgp --symmetric output.tar.pgp

decrypt:

pgp -d output.tar.gz | tar tv

Consider using proper asymmetric keys (public/private keys) for real protection