How to Password protect files and folders/directories on Linux using zip
I have previously discussed a simple trick to prevent other users from accessing your personal data. To summarise, all we did there was change the file permissions and ownership to root, so that whenever someone tries to access the folder through your account (assuming non-root), the system will throw a permission-denied error. Here is another similar trick to compress the content and password protect it.
Have you ever come across compressed/archived files which ask for password upon decompression? Yes, I am talking about the same thing here.
Say you have a folder named Secret and you want to hide it. We will use the zip software installed on most systems. Run the following command
[shredder12]$ zip --encrypt -r file Secret/
You will be prompted for password twice, enter them and the password protected compressed file will be created, file.zip. The -r option refers to recursively traversing the directory Secret and bundle and compress all the files together. So, in case of a single file, there is no need of this option.
But this methods sucks a bit. Thats because even though the other user won't be able to read the contents of the file but he will still be able to see all the files/filenames. e.g. after encrypting a directory using the above method, try opening it with file-roller(in terminal) or just double click on the icon. Here is an example:
One way to compensate this sucking part is by double password archiving, i.e. archiving the directory (regular or password protected) and then archiving this archive (this time passwd protected). This way the file-list won't be visible. The user will be prompted for password if he tries to access the first archive (secret.tgz in our case).
[shredder12]$ tar -cvzf secret.tgz Secret/
[shredder12]$ zip --encrypt secret secret.tgz
Enter password:
Verify password:
adding: secret.tgz (stored 0%)
Pros and Cons
Well, we all know this is definitely not the most efficient method of securing the data but one of the good things about this is its quickness. Ofcourse, one of the biggest drawback is the failure of its quickness in case of large files, e.g. - its definitely not the option, if you want to hide your p0rn stash
. But in case of text files or office docs, it may come in handy.






". Even though the guy is really nice but as you can see these accidental shutdowns or reboots can cause a lot of trouble :P. Well 





















Post new comment