Editing files with vi Commands

If you administrate servers you will almost definitely need to use vi command from the terminal as a GUI is not always possible, and vi is generally quicker to use I find.

These are my useful commands, ‘esc’ = the escape button.

Open a file:
[sourcecode language=”sh”]
vi filename
[/sourcecode]

Edit the file:
[sourcecode language=”sh”]
esc i
[/sourcecode]

Close the file:
[sourcecode language=”sh”]
esc :q
[/sourcecode]

Close and save the file:
[sourcecode language=”sh”]
esc :wq
[/sourcecode]