Compsmag is supported by its audience. When you buy through links on our website, we may earn an affiliate commission fee. Learn more

Create Password Protected Text File with vi and Command Line

Check tutorial of Create a Password Protected Text File with vi and the Command Line

So after a lot of requests from our users here is a guide about Create a Password Protected Text File with vi and the Command Line.

It is easy to create a password protected text file using the command line text editor ‘vi’. This is infinitely useful for privacy purposes, whether the secure file is for holding login credentials, various passwords, personal information, a private diary, or just about anything else you want to securely store in a single password-protected text file.

Vi is considered a bit advanced and has quite a steep learning curve, but it is very powerful. Fortunately, if you just want to encrypt a text document, vi can be fairly simple enough and we’ll cover some basic vi / vim commands to get you started with this goal.

Keep in mind that for the average experienced user, and for those who are not fans of the command line, using the more traditional security options of full disk encryption with FileVault, or the method of attaching files and folders to an encrypted image, could be simpler. because it is handled entirely through Mac OS X’s graphical interface and file system. With these two methods, you can also use a more well-known app like TextEdit (or something else) to edit the documents stored behind the password layer. Don’t forget to save the file and exit, then eject the virtual disk if you are following the route of a disk image, and to log out of the Mac when not using it if you try Filevault, otherwise miss those layers of password protection. Of course these two methods limit the readability of the files to a Mac, so if you want cross-platform access to the file in question, this is vi trick works well as it remains accessible from Linux and other Unix flavors with vi or vim. So do you want to go the command line route? Then proceed to encrypt text files with vi!

Create the password-protected text file

Creating the file is easy enough, run Terminal (/ Applications / Utilities / but you should know that by now if you’re comfortable with the command line) and use the following command syntax:

vi -x protected text

At the request of vi, enter a password twice to open vi with the encrypted text document. As usual with encrypted files, don’t forget that password or you won’t be able to open the file again.

So now you’re in vi. Of course, if you’re familiar with VI and VIM, you don’t need any help, but vi / vim can be a huge confusing headache for newbies to the advanced text editor. Without going into a huge vi tutorial, we’ll focus on just a few very simple vi commands that allow you to navigate the document, insert text, save, exit and exit both at the same time and save the encrypted text file.

Simple vi commands

  • i to insert text
  • Ctrl + F to scroll forward one screen
  • Ctrl + B to scroll back one screen
  • / (search term) + RETURN to search the file for “search term”
  • ESCAPE to enter, stop, save and stop vi commands, etc.
  • ESCAPE + ZZ to save and exit vi
  • ESCAPE +: q! stop without saving
  • ESCAPE +: w + RETURN to save without quitting

Yes, these are case sensitive. For example, to exit and save, ZZ must be in uppercase, making the save and exit command more like Shift + ZZ.

We’re intentionally keeping it simple here, but if you’re looking for an in-depth vi tutorial, here’s a great one from a leading engineering university.

For a practical example, this is what you would do to create the encrypted document with a password, enter some text, then save and exit. We will mark the most important commands with to indicate when to press a key:

vi -x encrypted_text file(type some things you want in the encrypted file, pretend you’re done now and want to quit and save)ZZ

You are now back at the command line. To go back to the document you can just open it as usual with vi:

vi encrypted_text_File

You must then enter the password to access the content.

All of this may seem a bit strange to those not used to vi / vim, but you’ll get the hang of it quickly.

Important: The protected file can only be accessed via vi / vim

This file and its contents are now only accessible through vi / vim, if you try to open it with another application or a command line tool you will only get gibberish up, preceded by a “VimCrypt” message, which looks something like this:

VimCrypt ~ 01!} ??? +?) ?? j2???^1Z??u4@???.t?????gҸ}? ų ?? 5p ?? #?]? M? ז ??? 7? a ??? 4? N7A ???? 7 ?? ?? 잏? 0 ?? +? 1Z ?? q? 7N? | ? you? ||?

You can also choose to just create a normal text file with any text editor of your choice, zip it with a password, then unzip it to modify or use the document, then zip it again with the same password, but it would be hard to argue that is easier than the above trickalthough an advantage of the zip approach is its cross-platform compatibility and the ability to modify the included documents through any application.

Thanks to Chris for the tip inspiration

Create a Password Protected Text File with vi and the Command Line Guide is free?

Starting from: Free
This guide is a free model
Free Trial: May be included, please check on the official site, we mentioned above.
The Create a Password Protected Text File with vi and the Command Line tutorial price is Free or Freemium. This means you can truly enjoy the Create a Password Protected Text File with vi and the Command Line guide.

The Create a Password Protected Text File with vi and the Command Line guide gives you an easy-to-use and efficient management and Create a Password Protected Text File with vi and the Command Line allows you to focus on the most important things. It’s friendly guide to use maybe you will love it and Create a Password Protected Text File with vi and the Command Line tutorial can be used on Linux, Windows or android devices.

Create a Password Protected Text File with vi and the Command Line: benefits

  • The Create a Password Protected Text File with vi and the Command Line tutorial is free .
  • Helps many users follow up with interest in a timely manner.
  • The price of the Create a Password Protected Text File with vi and the Command Line guide is free.

Create a Password Protected Text File with vi and the Command Line: FAQ

Tutorial Summary: Create a Password Protected Text File with vi and the Command Line

In this guide, we told you about Create a Password Protected Text File with vi and the Command Line; please read all steps so that you understand Create a Password Protected Text File with vi and the Command Line in case if you need any assistance from us, then contact us.

How this tutorial helping you?

So in this guide, we discuss the Create a Password Protected Text File with vi and the Command Line, which undoubtedly helps you.

What is actual time in which this method complete?

The time to complete the Create a Password Protected Text File with vi and the Command Line tutorial is 10+ minutes.

What are the supported Device?

Apple

What are the supported Operating system?

mac OS


Create a Password Protected Text File with vi and the Command Line Tutorial: final note

For our visitors: If you have any queries regards the Create a Password Protected Text File with vi and the Command Line, then please ask us through the comment section below or directly contact us.
Education: This guide or tutorial is just for educational purposes.
Misinformation: If you want to correct any misinformation about the guide “Create a Password Protected Text File with vi and the Command Line”, then kindly contact us.
Want to add an alternate method: If anyone wants to add the more methods to the guide Create a Password Protected Text File with vi and the Command Line, then kindly contact us.
Our Contact: Kindly use our contact page regards any help. You may also use our social and accounts by following the Whatsapp, Facebook, and Twitter for your questions. We always love to help you. We answer your questions within 24-48 hours (Weekend off).
Channel: If you want the latest software updates and discussion about any software in your pocket, then here is our Telegram channel.

Compsmag