Linux basic command and operation - vi command


Yeastar S-Series PBX is base on Asterisk platform and operating on Linux system. Linux is a open sources Unix operating system. PBX administrator can connect to SSH to acess Linux for exploring Asterisk and other system module. 

For how to login SSH of S-Series PBX please refer to : 

In this article, you will learn how to operate a basic and very usefull command: vi command.


vi editor and related command

vi is text editor in Linux system, it allows you to view, edit and write a text file on your terminal.

To open and edit a existing file, e.g. extensions.conf of Asterisk: 

#vi extensions.conf


You can also use vi to create a new empty file, e.g. to create custom configure file for extensions.conf and name it extensions_custom.conf:

#vi extensions_custom.conf

press i to enter insert mode:


if you do not save any change in this new file and quit, system will not keep this empty file.

There is another way to create a new file: touch+file name

#touch new_file.txt

#vi new_file.txt


touch will create a new empty file first, then you can use vi to edit it.

When you finish editting, use :wq to save and quit the vi editor.


In the vi interface, you will be able to move the cursor around to desired position. The arrow keys are most used, and below are other commonly used commands and keys you can use to move the cursor.

Command Operation
h,j,k,l move the cursor left,down,up,right
line number+G Move to line#; Move to the line with specific line number.


The escape key allows you to go to command mode at any point. At command mode, you will be able to manipulate the file.

Below are commands mostly used for file manipulation.

Command     Operation
i Insert mode; Insert character and string at current cursor position.
/ Pattern search; Search the matching strings in the file, press n to move to next matching string in forward direction.
:q and :q! Quitting; Use :q to quit the editor when you haven't made any changes in the file. :q! allows you to quit the editor without saving any changes in the file.
:wq Writting and Quitting; Use :wq to save all the changes you made and quit the editor.

Other usefull command: 

Command Operation
-R Read only mode; Open file in read only mode to prevent any overwirte of the file.
Ctrl+Z Job suspend; Put vi editor in backgroud and go to command shell. Use fg to returen to vi editor.


Please note that not all vi related commands are included here.



Have more questions? Submit a request


Please sign in to leave a comment.