zip
Updated: September 28, 2024
Zip will compress files into an archive.
ZIP TO ARCHIVE AND ENCRYPT
keeps original file
#zip a single file
zip -e archivename.zip filetoprotect.txt # adds password protect to a file (these are easy to crack tho)
#zip a folder recursively
zip -er archive.zip /path/to/directory/
Despite being created at the command line, you do not need to unzip the file from the terminal, it can be expanded from the Mac OS X Finder or within Windows using standard unzipping apps. Just double click on the file, then enter the password, and it will decompress.
unzip filename.zip
unzip -l filename.zip # shows what files are inside the zip and their sizes.
unzip -t filename.zip # test a zipped archive to check if there is any damage.
Keep in mind that password protected zip files are not encrypted with some super strong deep encryption method, so if you want a more secure file encryption, you may want to pass a regular zip file through openSSL with encryption using des3.
TAR
tar files also keep file permissions and ownership keeps orignal file
tar -xvf # extract
tar -cvf # compress
GZIP (Linux)
using gzip in terminal will not keep the orignal file
gzip -zxvf # extract
gzip -zcvf # compress
BZIP
bz -zxvf # extract
bz2 -jxvf # extract
bz -zcvf # compress
bz2 -jcvf # compress