In this guide, you will understand how to edit a file on command line using the Vi and Nano commands.
Follow the steps-
1) Using Vi command-
- Access the file using the Vi or Vim command-
- To enter insert mode, press the “I” key.
- Apply your preferred modifications. You can utilise the arrow keys to navigate within the file.
- To exit insert mode, press “ESC” key.
- Enter “:w” and press the “Enter key” to save the changes.
- Enter “:q” and press the “Enter” key to close this file.
- You can enter “:wq” to save and close the file.
- Keep in mind that if you make unintended changes, you can abort them by using “:q!” instead of “:w” or “:wq.” This command will exit Vi without saving the file.
2) Using Nano command-
- Access the file using the Nano command-
- Apply your preferred changes. You can utilise the arrow keys to navigate within the file.
- To close the file, press the “CTRL + X” keys. You will be prompted to save the changes. To save the changes, press “y” key and then to exit press enter key.
Was this article helpful to you? If you liked this article, then you will surely love our support. Get in touch of eukhost’s support experts; they are available 24×7.