• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to password protect a file Using VIM

2330

To Password Protect A File Using VIM

Password protecting a file is very easy in Linux and this tutorial covers the method to password protect a file using Vim. It is so simple, we will show you how to secure a file at the time of its creation as well as after opening it for modification.

Password Protecting A File

Before you begin, you need to install the full version of Vim, and for that simply run the following command.

[root@linuxhelp ~]# yum install vim
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
.
Installed:
  vim-enhanced.x86_64 2:7.4.160-2.el7                                                                              

Complete!

Vim has a -x option which enables you to use encryption when creating files. Once you run the vim command below, you’ ll be prompted for a crypt key:

[root@linuxhelp ~]# vim -x file.txt
~
~
~
Enter encryption key: *******
Enter same key again: *******

If the crypto key matches after entering it for the second time, you can proceed to modify the file.

crypto

In case you enter a wrong password (or no key), you’ ll see some junk characters.

junk

That’ s all! With this simple trick you can password protect a file via the Vim text editor in Linux.

Tags:
elijah
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What command is used to generated encrypted set of file?

A

Install and use mkpasswd

Q

Is this work with other editors ?

A

No it will work only with vim

Q

How to remove a encrypted password from the file.

A

You can update the original password with an empty password. Start vi/m with -x option, you’ll be prompted for new password, leave it empty/blank and press Enter twice.

Q

But if I write a python program with encryption enabled then the file doesn’t compile. What to do?

A

Try to compile without encryption. May be it will work.

Q

How can I reset the password using the current password? What If I forget the password later. Is there any way to reset the password without entering the old password? I mean is there something like security questions etc?

A

Do not forget the password, otherwise you’ll not be able to view the contents of the file again. And to update the password, open the file for editing and type [Esc] and :X then save changes to the file like this :w before closing it.

Related Tutorials in How to password protect a file Using VIM

Related Tutorials in How to password protect a file Using VIM

How to Set Up VIM Editor for Python Programming
How to Set Up VIM Editor for Python Programming
Feb 22, 2018
VIM Editor in Linux
VIM Editor in Linux
Mar 22, 2016
How to password protect a file Using VIM
How to password protect a file Using VIM
Feb 6, 2018

Related Forums in How to password protect a file Using VIM

Related Forums in How to password protect a file Using VIM

vim
caden class=
How to fix E575: viminfo: Illegal starting char in line
Jul 9, 2019
vim
jacob class=
Change true vi-compatible editor from Debian Vim-compatible
Nov 8, 2021
Linux
jayce class=
How to set number in vim permanently
Apr 20, 2017
Text Editor
ajinfernando class=
Vim editor : find and replace
Jan 29, 2018
vim
brayden class=
how to set password for VIM file
May 10, 2017
vim
logan class=
how to copy paste in vim editor
Feb 18, 2017
vim
benjamin class=
How to edit the file in remote server using vim editor
Feb 27, 2017
vim
mason class=
How to Remove Empty Lines in Vim Editor
Oct 18, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.