{"id":13568,"date":"2019-04-03T10:48:31","date_gmt":"2019-04-03T10:48:31","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13568"},"modified":"2019-04-03T10:48:31","modified_gmt":"2019-04-03T10:48:31","slug":"how-to-create-a-password-protected-zip-file-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-create-a-password-protected-zip-file-in-linux\/","title":{"rendered":"How to Create a Password Protected ZIP File in Linux"},"content":{"rendered":"<p><strong>ZIP<\/strong>\u00a0is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/password-protect-vim-file-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Password Protect a Vim File in Linux<\/a><\/p>\n<p>In this post, I will show you how to create a password protected zip file on the terminal in Linux. This will help you learn a practical way of encrypting and decrypting contents of zip archive files.<\/p>\n<p>First install\u00a0<strong>zip<\/strong>\u00a0utility in your Linux distribution using the package manger as shown.<\/p>\n<pre>$ sudo yum install zip    [On CentOS\/RHEL]\r\n$ sudo dnf install zip    [On Fedora 22+]\r\n$ sudo apt install zip    [On Debian\/Ubuntu]\r\n<\/pre>\n<h3>How to Create Password Protected ZIP in Linux<\/h3>\n<p>Once installed, you can use the\u00a0<strong>zip<\/strong>\u00a0command with\u00a0<code>-p<\/code>\u00a0flag to create a password protected zip archive called\u00a0<strong>ccat-command.zip<\/strong>\u00a0from the directory of files called\u00a0<strong>ccat-1.1.0<\/strong>\u00a0as follows.<\/p>\n<pre>$ zip -p pass123 ccat-command.zip ccat-1.1.0\/\r\n<\/pre>\n<div id=\"attachment_28208\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Create-Password-Protected-Zip-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28208\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Create-Password-Protected-Zip-File.png\" alt=\"Create Password Protected Zip File\" width=\"710\" height=\"120\" aria-describedby=\"caption-attachment-28208\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28208\" class=\"wp-caption-text\">Create Password Protected Zip File<\/p>\n<\/div>\n<p>However, the above method is absolutely insecure, because here the password is provided as clear-text on the command line. Secondly, it will also be stored in the history file (e.g\u00a0<strong>~.bash_history<\/strong>\u00a0for bash), meaning another user with access to your account (more especially\u00a0<strong>root<\/strong>\u00a0user) will easily see the password.<\/p>\n<p>Therefore, try to always use the\u00a0<code>-e<\/code>\u00a0flag, it shows a prompt allowing you to enter a hidden password as shown.<\/p>\n<pre>$ zip -e ccat-command.zip ccat-1.1.0\/\r\n<\/pre>\n<div id=\"attachment_28210\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Create-Password-Protect-Zip-Archive.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28210\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Create-Password-Protect-Zip-Archive.png\" alt=\"Create Password Protect Zip Archive\" width=\"630\" height=\"104\" aria-describedby=\"caption-attachment-28210\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28210\" class=\"wp-caption-text\">Create Password Protect Zip Archive<\/p>\n<\/div>\n<h3>How to Unzip Password Protected ZIP in Linux<\/h3>\n<p>To unzip and decrypt the content of the archive file called\u00a0<strong>ccat-command.zip<\/strong>, use the\u00a0<strong>unzip<\/strong>\u00a0program and provide the password you entered above.<\/p>\n<pre>$ unzip ccat-command.zip\r\n<\/pre>\n<div id=\"attachment_28212\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Decrypt-ZIP-Archive.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28212\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Decrypt-ZIP-Archive.png\" alt=\"Decrypt ZIP Archive\" width=\"627\" height=\"237\" aria-describedby=\"caption-attachment-28212\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28212\" class=\"wp-caption-text\">Decrypt ZIP Archive<\/p>\n<\/div>\n<p>That\u2019s It! In this post, I described how to create a password protected zip file on the terminal in Linux. If you have any queries, or other useful related tip\/tricks to share, use the comment form below ping us.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/create-password-protected-zip-file-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ZIP\u00a0is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives. Read Also:\u00a0How to Password Protect a Vim File in Linux In this post, I will show you how to create a password &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-create-a-password-protected-zip-file-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Create a Password Protected ZIP File in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13568","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13568"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13568\/revisions"}],"predecessor-version":[{"id":13569,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13568\/revisions\/13569"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}