nano is the simple terminal text editor found on almost every Linux server, and it is often the quickest way to fix a broken configuration file. This page gives you the essential nano shortcuts for troubleshooting, corrected for how nano really behaves, and sends you to our full guide for the advanced techniques.
Open a file with nano file, or at a known line with nano +LINE file. Save with Ctrl+O, exit with Ctrl+X, search with Ctrl+W, replace with Ctrl+\ and go to a line with Ctrl+_. Use nano -v to look without changing anything and nano -B to keep a backup. Editing server configuration applies to your own VPS; on shared hosting you edit only your own files, over jailed SSH if it is enabled on your account.
Marking and indenting blocks, regex search, macros, anchors, nanorc settings and real server examples are all in Advanced troubleshooting with nano: navigating and editing with precision.
1. Where this applies
- Your own VPS or server: you have root access and can edit system files such as web server, firewall and service configuration. Domain India VPS plans are self-managed.
- Domain India shared hosting: you cannot change server configuration. Jailed SSH access is available on every shared hosting plan (cPanel, DirectAdmin, Webuzo). It is off by default; ask support to enable it for your account. In the jail you can edit your own files, such as
.htaccessorwp-config.php. Measured in September 2026, the jailed shell on our cPanel and DirectAdmin servers has nano 2.9.8.
If you prefer not to use the terminal, the File Manager in your control panel has a built-in editor.
2. The essential shortcuts
| Action | Shortcut |
|---|---|
| Save (write out) | Ctrl+O, then Enter |
| Exit (asks to save if needed) | Ctrl+X |
| Search | Ctrl+W, then Alt+W for the next match |
| Search and replace | Ctrl+\ (A replaces all) |
| Go to a line | Ctrl+_ or Alt+G |
| Cut the current line | Ctrl+K |
| Paste | Ctrl+U |
| Undo and redo | Alt+U and Alt+E |
| Show cursor position | Ctrl+C |
Pressing Ctrl+K several times in a row collects the lines, so one Ctrl+U pastes them all back. That makes it easy to move a block of settings.
3. Safe habits when you troubleshoot
- Open at the reported line.When an error names a line,
nano +120 fileputs the cursor on it. - Look before you edit.
nano -v fileopens in view-only mode, so a stray key cannot change a sensitive file. - Keep the old version.
nano -B filesaves the previous version asfile~when you save. - Test, then reload.On your own server, run the service's config test (for example
nginx -torapachectl configtest) before you reload it.
4. Two corrections to older guides
- nano does not have tabs. Opening several files (
nano a.conf b.conf) gives you separate buffers. Alt+, and Alt+. switch between them, and Ctrl+X closes one at a time. nano $(grep 'error' logfile)does not open matching lines. The shell passes the matching text to nano as file names, so nano opens (or creates) files named after the words in your log. To work with matching lines, usegrep -n 'error' logfileto find the line numbers, then open the file you need to fix withnano +LINE. Never edit a log that a service is writing to; read logs withless,greportail -f.
A typing mistake in SSH, firewall or web server configuration on your own server can lock you out or take sites down. Keep your current session open until you have tested the change from a second session.
How do I save and exit in nano?
Press Ctrl+O and then Enter to save, and Ctrl+X to exit. If you press Ctrl+X with unsaved changes, nano asks whether to save them first.
How do I go to a specific line in nano?
Start nano with a plus sign and the line number, for example nano +120 filename, or press Ctrl+_ (or Alt+G) inside nano and type the line number.
How do I search and replace in nano?
Press Ctrl+\, type the text to find and press Enter, type the replacement and press Enter, then press Y to replace one match, N to skip it, or A to replace all.
Can nano open a file without letting me change it?
Yes. nano -v filename opens the file in view-only mode, which is a safe way to inspect sensitive configuration files.
Can I use nano on Domain India shared hosting?
Yes, if jailed SSH is enabled on your account; it is available on every shared hosting plan and off by default, so ask support to enable it. The jailed shell on our cPanel and DirectAdmin servers has nano 2.9.8, and you can edit only your own files.
Ready to work on the command line? Read how to enable and use jailed SSH, ask for it with a new support ticket, or get full root access on a self-managed VPS.
A self-managed VPS gives you full root access to edit any configuration file with nano or the editor of your choice.
See VPS plans