Have a Question?
Creating and editing a file via SSH
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
Creating a file using nano
- Log in to the server on SSH.
- Navigate to the directory where you want to create or edit the file.
- Next, type the nano command and then divide by space, enter the name of the file you want to create/edit.
[server] $ nano .htaccess
Next, start typing the contents of the file.- 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. - You can confirm the file by pressing Enter.
- Press Ctrl+X to exit the word processor.
Creating a file using vim
- Log in to the server on SSH.
- Navigate to the directory where you want to create or edit the file.
- Next, type the vim command, and then divide by space, enter the name of the file you want to create/edit.
[server] $ vim .htaccess
After the word processor starts, you can upload the file by pressing the i key as it changes to INSERT mode.
- When you upload the file with the required content, use Esc to exit the insertion mode.
To save the file, type :wq, and then use the Enter key to save the file.