Archiving files from the command line

How to use tar

Archive a bunch of files or a directory.

tar cfv archive.tar file1 file2 file3
tar cfv archive.tar directory/

Extract files.

tar xfv archive.tar

How to use zip and unzip

Here’s the basic usage.

zip archive.zip file1 file2 file3

The -r option allows you to traverse a directory recursively.

zip -r archivename.zip directory

You can encrypt the archive using the -e option.

zip -e archive.zip directory

Extract files.

unzip archive.zip