How to edit a file ?

Edit a file is crucial to manage a server.

There are plenty of text editors. The default is vi, and it is amazing. You should learn how to use it. If you're already used to emacs, use "mg" command instead.


Hare are some advices to start with vi.

To edit a file /etc/iloverocknroll, you'll enter:

vi /etc/iloverocknroll

You will see its content:

vi preview

Most of the time, you'll do this :

Still here ? 😎

Read the next lines if you want to go a little further.

There are three modes :

To save your changes, press ":" then enter "w" and "Return". You can exit vi using ":q". To do both at the same time, enter ":wq".

To cancel changes, enter "u". To cancel again, press "." : it repeat the last action.

To search in the file, enter "/" the write what you're looking for.

If you want to discard your changes, enter ":q!"

Other tips :