2020年7月30日 星期四

[Linux 常見問題] Compressing folders with password via command line

Source From Here
Question
I would like to know whether it is possible to do the following via CLI.

I have a Folder F which contains several sub folders and some files. I want to compress folder F into .zip file with the "password-only-extract".

How-To
Go to the relevant folder using the cd command like this:
# cd /path/to/folder/

(If your folder )

Then, type in your terminal:
# zip -er F.zip F

This will prompt you for a password. Give it, and that will create a password-protected zip file from that folder.
-e enables encryption for your zip file. This is what makes it ask for the password.
-r makes the command recursive, meaning that all the files inside the folder will be added to the zip file.
* F.zip is the name of the output file.
* F is the folder you want to zip.

There is an option called -P that will allow you to pass the password in the command itself, but that is not good because there is always the threat of over-the-shoulder peeking. Also other users can see the password by using ps -ef command if you use -P switch. With that -P switch, the command will look like this:
# zip -P password -r F.zip F

Visit man zip for more information.

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...