VI - A quick Tutorial

Any questions about the Command Line Interface can be placed here!
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/su ... p?lang=enu



2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
jotrago
Rookie
Rookie
Posts: 32
Joined: Wed Sep 05, 2012 2:02 pm

VI - A quick Tutorial

Unread post by jotrago » Sun Dec 01, 2013 8:59 pm

DS Console CLI Intro, Commands and Locations

The DS implements a subset of the BusyBox Command Shell commands
http://www.busybox.net/

It provides vi as the text editor

Quick Guide to VI
=================


A brief How To use the VI text editor on a DS

Assuming that the only reason to use VI is to edit System Files, the following is what you need to know

Access DS with your favourite Telnet or SSH Client
I used Putty for this tutorial

login as root with Admin Password

I prefer to CD to the desired directory, then simply work with filename

vi path/file Opens an existing file, or creates "file"
Path must exist
Vi doesn't create directories
Displays the top screenfull of lines
With a status line at the bottom

Key Concept
VI is a "Modal" Editor it is either in :-

Command Mode (By Default)
Typing is interpreted as commands - BE CAREFUL
OR
INSERT mode
Typing is interpreted as text to be placed in the file

In Command Mode type I (letter I) to enter Insert mode
In Insert Mode type ESC to Escape to Command mode

If in doubt press ESC twice to ensure you are in command mode

The commands you need
:w newfilename - write (save) the file to newfilename from the command mode
Good way to make a backup BEFORE you start
:wq write and quit
:q! quit without saving

Editing a File
Open your file, hit I for Insert Mode

MOVING AROUND (in insert mode)
Arrow Keys
Page UP Down
HOME - END of line

EDITING
Type to insert text
Backspace & Delete work

SAVE & QUIT
ESC back to command mode
:wq

cat filename to check your work

See http://en.wikipedia.org/wiki/vi if you need more detail
Own DS212 DSM 5.0-4482 2 x WD20EFRX-68EUZN0 2TB NAS Class Drives: Also work on RS2212+ DS812+
Interest in Backup Replication Synchronisation

Post Reply

Return to “Command Line Interface”