SSH & Terminal Access

Mastering nano for Troubleshooting: Essential Tips and Techniques for System Administrators

By the Domain India teamPublished 5 min read
Knowledge base article
Contents (4 sections)

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.

Key takeaways

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.

For the full guide, see Advanced Troubleshooting with nano

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 .htaccess or wp-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

ActionShortcut
Save (write out)Ctrl+O, then Enter
Exit (asks to save if needed)Ctrl+X
SearchCtrl+W, then Alt+W for the next match
Search and replaceCtrl+\ (A replaces all)
Go to a lineCtrl+_ or Alt+G
Cut the current lineCtrl+K
PasteCtrl+U
Undo and redoAlt+U and Alt+E
Show cursor positionCtrl+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

  1. Open at the reported line.
    When an error names a line, nano +120 file puts the cursor on it.
  2. Look before you edit.
    nano -v file opens in view-only mode, so a stray key cannot change a sensitive file.
  3. Keep the old version.
    nano -B file saves the previous version as file~ when you save.
  4. Test, then reload.
    On your own server, run the service's config test (for example nginx -t or apachectl 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, use grep -n 'error' logfile to find the line numbers, then open the file you need to fix with nano +LINE. Never edit a log that a service is writing to; read logs with less, grep or tail -f.
Keep a way back in

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.

Need root access to your own server?

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

Ready when you are

Get DirectAdmin hosting from ₹100/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app