Sun

Creating and editing a file via SSH

  1. Home
  2. Knowledge Base
  3. Hosting
  4. VPS Hosting
  5. Creating and editing a file via SSH

Two of the most popular ways to create and edit files in Linux are:

  • nano – a simple and straightforward tool intended for creating files and text editing in Linux;
  • vim  – a more complex tool intended for creating files and text editing in Linux.

Using “nano” for creating and editing a file:

1. Log in to the Linux server.

2. Move to the necessary directory using the command “cd”.

3. To create a file type nano and the file name. For example, type nano index.html to create the “index.html” file:

A new file creates and opens the window:

4. Once the windows open, you can start typing the necessary text which appears in the redactor window. It seems like in the picture below:

5. Once all the necessary text is added, press Ctrl + X to save the file.

6. If adjusted text should be saved to a different file press Ctrl + O and confirm the new file name.

7. All changed should be confirmed by pressing Enter.

Using “vim” for creating and editing a file:

1. Log in to the Linux server.

2. Move to the necessary directory using the command “cd”.

3. To create a file, type vim, and the file name. For example, type vim index.html to create the “index.html” file:

A new file creates and opens the window:

4. By default, redactor is locked, so to start typing, press “i” to enable INSERT mode:

5. Now you can start typing in the file:

6. Once all the necessary text is added press “ESC” to disable the INSERT mode (–INSERT– symbol disappears from the bottom left corner).

7. To save the file type (:) and Exit

To change a file name without its opening use the command “mv”:

Was this article helpful?

Related Articles