{"id":966,"date":"2018-10-19T18:55:53","date_gmt":"2018-10-19T18:55:53","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=966"},"modified":"2018-10-23T01:08:30","modified_gmt":"2018-10-23T01:08:30","slug":"how-to-password-protect-a-file-in-vim-editor","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/19\/how-to-password-protect-a-file-in-vim-editor\/","title":{"rendered":"How to Password Protect a File in Vim Editor"},"content":{"rendered":"<p>The Vim editor can be called a programmer\u2019s text editor. It is upwards compatible with the Vi editor and can be used to write and edit plain files and programs. Along with the many enhancements it provides, Vim Editor can be used to password protect your text files. In this article, we will explain the installation of the Vim Editor and then using it to create and open encrypted files. These files can be used for privacy purposes and are only accessible through Vim when you know the password to them.<\/p>\n<p>The commands and procedures mentioned in this article have been run on an Ubuntu 18.04 LTS system.<\/p>\n<h2>Password protect a file in Vim<\/h2>\n<h3>Install the Vim Editor<\/h3>\n<p>Let us first install the Vim editor on our Ubuntu system. Vim is available on repositories of all major Linux distributors. Open your Linux Terminal either through the system Dash or the Ctrl+Alt+T shortcut. Then enter the following command as root to install the Vim text editor:<\/p>\n<p>$ sudo apt-get install vim<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Install Vim Editor\" width=\"474\" height=\"353\" \/><\/p>\n<p>The installation procedure requires your confirmation to proceed through a Y\/n prompt; enter y in order to continue installation.<\/p>\n<h3>Create a Password Protected File<\/h3>\n<p>After the installation is complete, let us proceed with creating a password protected file. Enter the following command in order to do so:<\/p>\n<p>Syntax:<\/p>\n<p>$ vim -x [filename].txt<\/p>\n<p>Example:<\/p>\n<p>$ vim -x privatefile.txt<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Make a password protected file with vim\" width=\"342\" height=\"55\" \/><\/p>\n<p>When you create a text file through the above command, the -x switch indicates that you want to encrypt your file. Therefore, you will be displayed the following message where you can provide an encryption key and then re-confirm it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Enter the password\" width=\"502\" height=\"66\" \/><\/p>\n<p>When you enter the encryption key and hit enter, a blank file by the specified name will open in the Vim editor. You can insert some text here by first pressing the \u2018i\u2019 key. You can then quit and save the file by pressing Esc+wq.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"File content\" width=\"397\" height=\"296\" \/><\/p>\n<p>Now, you have successfully created a password protected text file through the Vim editor.<\/p>\n<h3>Open a Password Protected File<\/h3>\n<p>If you try to open it through any other text editor, you will see some encrypted characters rather than the text you wrote. For example, we tried to open our file through the Nano editor through the following command:<\/p>\n<p>$ nano privatefile.txt<\/p>\n<p>This is how our encrypted file looks like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Encrypted file\" width=\"618\" height=\"297\" \/><\/p>\n<p>Lets us quit and try to open the file through the Vim editor because a file encrypted through Vim can only be opened in Vim.<\/p>\n<p>Enter the following command to open the file:<\/p>\n<p>Syntax:<\/p>\n<p>$ vim [filename].txt<\/p>\n<p>Example:<\/p>\n<p>$ vim privatefile.txt<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Open file with Vim\" width=\"316\" height=\"56\" \/><\/p>\n<p>Since it is a password protected file, the system will ask you to enter the encryption key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Enter the password\" width=\"502\" height=\"56\" \/><\/p>\n<p>When you enter the encryption key once and then hit Enter, your file will open in the Vim editor displaying its original contents in decrypted form as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/vitux.com\/wp-content\/plugins\/a3-lazy-load\/assets\/images\/lazy_placeholder.gif\" alt=\"Decrypted file content\" width=\"345\" height=\"94\" \/><\/p>\n<p>So you have seen how an encrypted file can be created and opened through the Vim editor based on the simple steps described in this article.<\/p>\n<p><a href=\"http:\/\/lxer.com\/module\/newswire\/ext_link.php?rid=261835\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Vim editor can be called a programmer\u2019s text editor. It is upwards compatible with the Vi editor and can be used to write and edit plain files and programs. Along with the many enhancements it provides, Vim Editor can be used to password protect your text files. In this article, we will explain the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/19\/how-to-password-protect-a-file-in-vim-editor\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Password Protect a File in Vim Editor&#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-966","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\/966","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=966"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/966\/revisions"}],"predecessor-version":[{"id":1384,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/966\/revisions\/1384"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}