Have a Question?

Categories

Creating and editing a file via SSH

You are here:
< All topics
Table of contents

There are several ways to create a file through SSH. In this article, we will present the file creation with two types of word processors.

  • nano – for beginner users
  • vim – for advanced users

If you are editing files from a cumbersome command line, we recommend that you create a file via FTP, you can use this description below:
Create and modify a file via FTP

The following description is just an example of how to create or modify a file using SSH. Following the description, make sure you create the file at the right place. If you modify it, edit the file you want.

Creating a file using nano

  1. Log in to the server on SSH.
  2. Navigate to the directory where you want to create or edit the file.
  3. Next, type the nano command and then divide by space, enter the name of the file you want to create/edit.
    [server] $ nano .htaccess

  4. Next, start typing the contents of the file.
  5. When you have uploaded the file with the required content, hold down the Ctrl key and press the O key (Ctrl + O).


    At the bottom of the screen, the editor will ask you again about the name of the file you previously specified.

  6. You can confirm the file by pressing Enter.
  7. Press Ctrl+X to exit the word processor.

Creating a file using vim

  1. Log in to the server on SSH.
  2. Navigate to the directory where you want to create or edit the file.
  3. Next, type the vim command, and then divide by space, enter the name of the file you want to create/edit.
    [server] $ vim .htaccess

  4. After the word processor starts, you can upload the file by pressing the i key as it changes to INSERT mode.
  5. When you upload the file with the required content, use Esc to exit the insertion mode.

  6. To save the file, type :wq, and then use the Enter key to save the file.
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we correct this article?
Please submit the reason for your vote so that we can improve the article.
Tags:
Previous Creating and editing a file via FTP
Next Creating Menu