Editing files in SSH using VI

VI is a Linux text editor that can edit most of the files under a Linux architecture (text files, php, cfm, cfc, etc).

To open a file in VI editor, type the following:

vi FileName

For a file named test.txt, it would be:

vi test.txt

Once the file has been opened, press the "insert" or "i" key on your keyboard to enter edit mode.

The "Esc" key will allow you to leave the edit mode, but not the VI editor.

Here is the list of the most used commands in the VI editor:

  • :q! - Forces the editor to exit without saving.
  • :w - Saves the changes that have been made to the file.
  • :wq - Saves the changes that have been made to the file and then exits.
  • :# - Where # is a number - Brings you to line number #
  • :$ - Brings you to the last line of the file
  • :0 - Brings you to the first line of the file
  • :/word - This will search for the string "word" in the file. By pressing "n" you can view the other search result.
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

rkhunter (Rootkit Hunter) Install Guide

What is rkhunterrkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits,...

List of available VPS Templates

Below is a list of the available templates you can select to use on your Virtual Private Servers...

How to install a .bin file using SSH on Ubuntu/CentOS

Bin files are Linux self extracting binary files that is commonly used for server side software....

Can you install Zope & Plone CMS onto my VPS or dedicated server?

We can install and setup the latest Zope & Plone CMS onto any of our VPS or dedicated servers...