In Linux, there are different editors to edit text files. The most wide-spread editor is vi. Find below the basics on how to use vi:
Open a text file:
vi /etc/lighttpd/lighttpd.conf
There are 2 modes in vi:
- Command mode (you are in this mode right after starting vi)
You can use keyboard keys to navigate, delete, copy, paste, save the file, quit vi and do a number of other tasks - except entering text - Insert mode (-- INSERT -- will appear in the bottom line of vi)
You can enter text, use the Enter key to add a new line, and also navigate with the keyboard keys
To change to Insert mode, press i
To change to Command mode, press Esc
The following commands can be used in Command mode:
- :w Save (write) the file to disk and continue editing
- :q! Quit vi without saving the file to disk (discard changes)
- :wq Save the file to disk and quit vi
On some Linux distros there is an easier to use editor: Nano
I normally use the nano editor on the terminal, but i must say that this tool has been around for nearly 50 years in the unix world. It still holds it's ground.