Many of our guides ask you to change a settings file. On Ubuntu, the simplest editor for that is nano: it works in the SSH window and shows its most important keys at the bottom of the screen. Tested with nano 8.7 on Ubuntu 26.04 LTS.


1. Open a File

nano /etc/hostname

Files in /etc belong to root; as a normal user, use sudo nano /etc/…. If the file does not exist yet, nano creates it when you save. Before you change an important file, keep a copy: cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.

2. The Keys at the Bottom

The two lines at the bottom list the keys. ^ means Ctrl and M- means Alt. The ones you need most:

  • Ctrl+O then Enter: save (Write Out). nano confirms with a line like [ Wrote 3 lines ].
  • Ctrl+X: exit. With unsaved changes, nano asks Save modified buffer?: Y saves, N throws the changes away.
  • Ctrl+W: search (Where Is); type the text and press Enter. Alt+W finds the next match.
  • Ctrl+K: cut the whole line; Ctrl+U: paste it. Several Ctrl+K in a row cut several lines.
  • Alt+U: undo; Alt+E: redo.
  • Ctrl+/: go to a line number, useful when an error message names a line.
  • Ctrl+G: help with all keys.

3. Paste From Your Computer

To paste text that you copied on your computer, use the paste of your SSH program, not Ctrl+U: right-click in PuTTY or in the Windows Terminal, Ctrl+Shift+V in most Linux terminals, Cmd+V on macOS. Check the indentation afterwards: settings files such as YAML need exactly the spaces shown.

Tips

  • Show line numbers: open the file with nano -l.
  • A file that a service reads is only used after a restart or reload of that service, for example systemctl reload ssh. Our guides name the command each time.
  • Many programs can check their settings before you apply them, for example sshd -t or nginx -t. Use it: a typo then does not stop the service.

Related Guides

View all Linux guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)