Making Nano a Daily Driver: Practical .nanorc Configuration for Sysadmins
Stop re-configuring Nano every session. A practical ~/.nanorc gives you line numbers, syntax highlighting, multi-buffer editing, and cursor-position memory — turning a basic editor into a reliable daily tool for config work.
31 May 2026, 00:45 UTC

The problem: Nano forgets everything when you close it
You open /etc/nginx/nginx.conf, make a change, save, and exit. Next week you open /etc/ssh/sshd_config and line numbers are gone, tabs are spaces, and keywords are plain white text. Nano starts clean every time unless you tell it otherwise.
For occasional edits that's fine. For daily configuration work across dozens of files, the friction adds up. The fix is a single file: ~/.nanorc.
What a minimal useful .nanorc looks like
Create ~/.nanorc in your home directory (no special permissions needed; your user owns it). Paste this block, save, then open any file to verify:
# ~/.nanorc — persistent Nano settings
set line numbers
set autoindent
set tabsize 4
set tabstospaces
set mouse
set constantshow
set minibar
set positionlog
set softwrap
set atblanks
# Syntax highlighting — include the shipped definitions
include "/usr/share/nano/*.nanorc"
Run nano /etc/hosts (or any file). You should see line numbers in the left margin, the cursor position in the status bar, and soft-wrapped long lines. If you don't, check that the include path exists — on some distributions it's /usr/local/share/nano/*.nanorc or /opt/homebrew/share/nano/*.nanorc on macOS.
Why each setting matters for config work
- line numbers — match error messages like \"nginx: line 47: syntax error\" without counting manually.
- autoindent + tabsize 4 + tabstospaces — keep YAML, Python, and indentation-sensitive configs consistent.
- mouse — click to place the cursor, drag to select, scroll wheel to navigate. Works in most modern terminals (gnome-terminal, iTerm2, Windows Terminal, SSH with
-Xforwarding disabled). - constantshow — always show line/column in the status bar; minibar removes the top title bar for more editing space.
- positionlog — Nano remembers the last cursor position per file. Open
sshd_configagain and you land where you left off. - softwrap + atblanks — long single-line configs (cloud-init user-data, long
ProxyPasslines) wrap at word boundaries instead of mid-word. - include \"*.nanorc\" — loads syntax definitions for ~100 languages. Keywords, strings, comments, and numbers get color-coded automatically by file extension.
Worked example: editing a multi-file service change
Scenario: you're rotating TLS certificates for a web stack. You need to update paths in three files:
/etc/nginx/sites-available/example.com/etc/haproxy/haproxy.cfg/etc/prometheus/prometheus.yml(for the blackbox exporter target)
Open them in one Nano session:
nano /etc/nginx/sites-available/example.com \\\n /etc/haproxy/haproxy.cfg \\\n /etc/prometheus/prometheus.yml
Nano loads each file into its own buffer. Switch between them with Alt+, (previous buffer) and Alt+. (next buffer). The status bar shows the current filename and modified state.
Edit the certificate path in the nginx buffer, hit Alt+., edit haproxy, hit Alt+., edit prometheus. Save all with Ctrl+O (write out) in each buffer, or Ctrl+X to exit — Nano prompts per modified buffer.
This beats opening three separate SSH tabs or screen/tmux panes when you just need quick, coordinated edits.
Trade-offs you should know
| Limitation | Impact | Workaround |
|---|---|---|
| No Language Server Protocol (LSP) support | No go-to-definition, hover docs, or real-time diagnostics for code. | Pair with lsp-zero in a separate terminal, or use VS Code / Neovim for development; keep Nano for config. |
| Large file performance | Files > 50 MB load slowly; > 500 MB may OOM. | Use less, sed, awk, or vim -u NONE for huge logs. |
| No persistent undo across sessions | Undo history resets on close. | Commit config to git before editing; use git diff to review. |
| Syntax highlighting is regex-based | Complex embedded languages (e.g., Jinja2 inside YAML) may mis-color. | Acceptable for reading; for heavy templating, use an editor with tree-sitter. |
Verify your setup in 30 seconds
nano --version— confirm you're on 5.x or newer (syntax include glob works reliably).nano ~/.nanorc— the file itself should show line numbers and colored keywords (set,include).nano /etc/passwd— line numbers, cursor position, soft wrap visible.nano /etc/nginx/nginx.conf— nginx directives colored, comments dimmed.- Open two files, toggle with Alt+. — buffer switch works.
If any check fails, re-check the include path and that ~/.nanorc ends with a newline.
Closing action
Add the example .nanorc above to your dotfiles repo. Next time you provision a server or spin up a container, copy it in. You'll get a consistent, readable editing environment everywhere without installing plugins or learning chorded keybindings. Nano stays simple — your config just makes it yours.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.