Saturday, September 24, 2011

// // Leave a Comment

How to edit a file via ssh

To edit a file via ssh we have the following editors: 

  • nano / pico
  • vim
  • vi
  • touch











Suppose we want to edit a file /home/w3tools/index.html using vim editor.


To edit this file use the following steps:


        1. Log in to server via ssh using any client (recommended: Putty)


        2. Run the following commands.
vim /home/w3tools/index.html
        3. Now the file index.html will be opened. To edit the file press i. Now make changes in the file.
     
        4. To save the file Press Esc then wq .


Your file will be updated successfully.
If index.html doesn't  exist it will be created automatically.


Note: To exit file editor without saving the file press Esc then q.