How do I edit a Linux file through SSH using Nano?

The following assumes you’ve already established an SSH connection using a utility like putty.  Nano uses keystroke combinations to execute certain functions. The keystrokes consist of first pressing and holding the control key and then pressing an additional key. The following are common functions:

  • CTRL+o: this will save the file
  • CTRL+x: this will exit the file
  • CTRL+w: this will allow you to enter a phrase to search the file
  • CTRL+k: this will allow you to cut 1 or more lines of text
  • CTRL+u: this will allow you to uncut lines of text that were cut using CTRL k (similar to pasting text)
  • CTRL+v: this will advance the file to the next page
  • CTRL+y: this will move the file to the previous page
  • CTRL+t: this will run spellcheck on the file

To create a new file using Nano, please follow these steps:

  1. Open Nano by typing the following:
    nano
  2. Enter the information to wish to put in the file.
  3. Save the file (keystroke listed above).
  4. Enter the name of the file.
  5. Press Enter.

To edit an existing file using Nano, please follow these steps:

  1. Open Nano by typing the following:
    nano filename
  2. Edit the information in the file.
  3. Save the file (keystroke listed above).
  4. Press Enter to save the file with the same name.