Nano Editor Basics: Edit Files in the Terminal Without Panic
Nano is the simplest terminal text editor and is installed on almost every Linux server. How to open a file, save with Ctrl+O, exit with Ctrl+X, search, cut and paste lines, jump to a line number, and edit files that need sudo.
Nano is a small text editor that runs in the terminal. It's on almost every Linux server and Mac, and unlike Vim, it works the way you'd expect: you open a file and start typing.
You'll use it to edit config files over SSH, write a quick .env file, or fix one line on a server.
Open a file
nano notes.txt
If the file doesn't exist, nano creates it when you save. For system files that need admin rights:
sudo nano /etc/nginx/sites-available/myapp
The two shortcuts you need
The bottom of the screen lists shortcuts. ^ means Ctrl, and M- means Alt.
Ctrl+O— save ("Write Out"). Press Enter to confirm the file name.Ctrl+X— exit. If there are unsaved changes, it asks: pressYto save,Nto discard, then Enter.
Most of the time, Ctrl+X, Y, Enter is all you need.
Other useful shortcuts
| Shortcut | Action |
|---|---|
Ctrl+W |
Search ("Where is") — then Alt+W for the next match |
Ctrl+\ |
Search and replace |
Ctrl+K |
Cut the current line |
Ctrl+U |
Paste the cut line(s) |
Ctrl+_ or Alt+G |
Go to a line number |
Alt+U |
Undo |
Alt+E |
Redo |
Ctrl+C |
Show the current line number |
Alt+N |
Toggle line numbers (newer versions) |
To move a block of lines: press Ctrl+K repeatedly to cut each line, move the cursor, then Ctrl+U to paste them all.
Pasting from your computer
Copying text from your browser and pasting into nano over SSH uses your terminal's paste: usually Ctrl+Shift+V on Linux, Cmd+V on Mac, or right-click in Windows Terminal. Nano's own Ctrl+U only pastes what you cut inside nano.
Jumping to an error line
When an error says nginx: [emerg] ... in /etc/nginx/nginx.conf:42, open the file at that line directly:
sudo nano +42 /etc/nginx/nginx.conf
Common gotchas
- "Permission denied" when saving — you opened a protected file without
sudo. Exit without saving, then reopen withsudo nano. (Linux File Permissions) - Long lines wrap or scroll sideways — that's display only; nano doesn't add line breaks unless "hard wrap" is on. Start with
nano -wto make sure it won't wrap long lines in config files. - YAML and Python care about spaces — nano inserts real tab characters when you press Tab by default. Use spaces, or start nano with
nano -Eto convert tabs to spaces. (What Is YAML?)
Make nano your git editor
git config --global core.editor "nano"
Now commit messages open in nano instead of Vim.
The summary
nano filenameto open,Ctrl+Oto save,Ctrl+Xto exit.Ctrl+Wsearches,Ctrl+K/Ctrl+Ucut and paste lines.- Use
sudo nanofor system files.
EasySpawn lets you ask Claude Code to make server config changes in plain English, with a diff to review, so you only open nano when you want to. See how it works or join the waitlist.
Related: Basic Linux Commands · SSH Into a Server · Environment Variables Explained · Terminal for Beginners
Keep reading
What Is nvm? Install and Switch Node.js Versions the Easy Way
nvm (Node Version Manager) lets you install several versions of Node.js and switch between them per project. How to install it on Mac and Linux, the Windows options, the commands you'll actually use, .nvmrc files, and alternatives like fnm and Volta.
What Is n8n? Workflow Automation (and AI Agents) Explained Simply
n8n is a workflow automation tool: you connect apps and APIs with visual nodes so that something happening in one place triggers actions in others. What n8n is used for, how workflows and nodes work, its AI agent features, the fair-code licence, and cloud vs self-hosted.