Introduction
The procedure below will show you how to edit a file on the command-line using the Vi and Nano commands.
Procedure
Vi:
1. Open the file using the vi or vim command:
vi example_file
2. Press the "i" key to enter insert mode.
3. Make your desired changes. Note that you can use the arrow keys to move around in the file.
4. Press the escape "ESC" key to exit insert mode.
5. Type ":w" and press the enter key to save your changes.
6. Type ":q" and press the enter key to close the file. (Optionally, type ":wq" to save and close the file.)
Please note that any unintentional changes can be aborted by using ":q!" instead of ":w" or ":wq". This will close Vi without saving the file.
Nano:
1. Open the file using the nano command:
nano example_file
2. Make your desired changes. Note that you can use the arrow keys to move around in the file.
3. Press the "CTRL + X" keys to close the file. You will be prompted to save your changes. Press the "y" key to save your changes and then press enter to exit.