Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I compress two folders into archive file (zip, gzip or something like that) with a password on the files?

For example I have folder structure:

  • rootDir
    • dir1
    • dir2
    • dir3
    • dir4

I need bash command to add dir2 and dir4 to same archive file compressed with a password on it.

share|improve this question

migrated from stackoverflow.com Sep 10 '09 at 17:55

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

up vote 7 down vote accepted
zip -er filename.zip dir2 dir4

The zip command is widely available; if not on your system, look for a zip package or similar.

The -e flag specifies encryption is to be used on the zipfile; you'll be prompted for a password.

The -r flag specifies recursion; all the files in dir2 and dir4 will be included.

The resulting zipped, encrypted file containing dir2 and dir4 will be placed at filename.zip.

share|improve this answer
    
This is good, how do I do it for all folders , files and subfolders (recursive) ? And another question, how do I provide password without prompt ? –  Perica Zivkovic Sep 10 '09 at 18:01
1  
so the answer I was looking for is: zip -rP "password" filename.zip dir2 dir4 –  Perica Zivkovic Sep 10 '09 at 18:42
1  
Note however, that zip's built-in encryption is fairly insecure: math.ucr.edu/~mike/zipattacks.pdf . If you want more than protection from casual peeping, use a real encryption software (such as GnuPG or TrueCrypt). –  sleske Jan 4 '10 at 11:25
add comment

Compress with your favorite unix command (mine is 'tar cfj' for a BZip2 tarball).
Then encrypt with bcrypt.

Bcrypt is a cross platform file encryption utility.

But, they say bcrypt is no longer safe (! ;-)),
Well, change to TrueCrypt (it too is cross platform -- easycrypt).

Tip: Encryption after compression makes life much more interesting.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.