Knowledge Base
MilesWeb / Web Hosting FAQ

How to Create and Edit a File via SSH?

Approx. read time : 3 min

Watch this video for a step by step process on how to create and edit a file via SSH

You can create and edit a file when logged into a MilesWeb server via SSH. This article explains the use of two text editors:

nano — Best for beginners.
vim — Offers more features than ‘nano’, but also difficult to use. It is a good choice for advanced users.

Note: If you don’t want to edit files in a terminal, you can check the below article:

How to Create and Edit a File via FTP?

Create and Edit a File Using ‘nano’

‘nano’ is the best choice for newbies as it is easier to use than ‘vim’. Check the steps below to create and edit a file using ‘nano’.

1. Log into your server using SSH.

2. Go to the directory location where you want to create the file, or edit an existing file.

3. Type nano along with the name of the file. For example, if you want to create (or edit) a new file named as index.html, run the following:

[server]$ nano index.html

You will see a new file open with the name index.html as below:

4. Now, you can type your data into the file.

5. After you complete typing the data, save the file and hold down the Ctrl key and press the letter ‘O’ (Ctrl + O).

You will be prompted to confirm the file name that is already set as ‘index.html’ as below:

6. Next, click the ‘Enter’ key on your keyboard for saving the file.

7. Then, click Ctrl + X to close ‘nano’ and go back to your shell.

Create and Edit a File Using ‘vim’

1. Log into your server using SSH.

2. Go to the directory location where you want to create the file, or edit an existing file.

3. Type in vim along with the name of the file. For example, if you want to create (or edit) a new file named as test.html, run the following:

[server]$ vim test.html

The ‘vim’ editor will get displayed which might seem to be confusing at first as you won’t be able to type into the file yet:

4. On the keyboard, click the letter ‘i’ to enter INSERT mode in ‘vim’.

You will now see — INSERT — on the bottom left:

5. Type the data into the file now.

6. After you are done with editing the file, click the ESC key. You will be taken out of INSERT mode and — INSERT — will get disappeared from the bottom left of your terminal.

7. Save the file by typing in a colon followed by wq as below:

:wq

You will see :wq appeared on the bottom left:

8. Now, on your keyboard click the ‘Enter’ key to save.

Changing the Name of a File

If you wish to change the name of a file, use the mv command. For example, a file named ‘file1.txt’ changes to ‘file2.txt’.

[server]$ mv file1.txt file2.txt

That’s it! You can now create and edit a file via SSH.

Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna