How to Use nano to Edit File Like an Expert

When I first started using Linux, I found it tricky to edit files from the command line. I didn’t know which editor to use. Some people said “use Vim,” but it felt like learning how to fly a spaceship. Then I found nano—a small, simple text editor that just works.

In this guide, I’ll show you how to use nano like a pro. We’ll go through the basics, plus some clever shortcuts. I’ll keep things easy to follow, and even add a few jokes along the way. Think of this as your beginner’s map to navigating files with confidence.


What Is nano?

nano is a command-line text editor. It runs in the terminal, which is that black screen where you type commands.

Unlike fancy editors like VS Code or Sublime Text, nano doesn’t use a mouse. You control it all with your keyboard. That might sound scary, but trust me—once you get used to it, it’s actually faster.

Here’s what makes nano great:

  • It’s pre-installed on most Linux systems
  • It’s easy to use
  • It shows keyboard shortcuts at the bottom
  • It doesn’t need a mouse or a lot of setup

I like to think of nano as the Swiss Army knife of text editors. Small, but mighty.


When Do You Use nano?

You can use nano to edit all kinds of files:

  • Configuration files like /etc/hosts or /etc/nginx/nginx.conf
  • Shell scripts like backup.sh
  • Log files (just be careful not to break them)
  • Simple notes or to-do lists

Whenever you’re inside a terminal and need to change a file, nano is ready.


Opening a File with nano

Let’s start with the basics. Open your terminal and type:

nano filename.txt

If the file exists, nano will open it. If it doesn’t, nano will create it for you.

Pretty neat, right?

Here’s how the screen looks:

  • At the top: the file name
  • In the middle: the text in the file
  • At the bottom: keyboard shortcuts (like ^X for Exit—where ^ means Ctrl)

How to Move Around

Once you’re inside nano, you can move your cursor with the arrow keys. Left, right, up, down—they all work like you’d expect.

If you want to jump to a specific line number, press:

Ctrl + _ 

Then type the line number and hit Enter.

That shortcut saves time when editing big files. I use it often when fixing config files with over 100 lines.


Writing, Saving, and Exiting

To type in nano, just… type. It works like Notepad.

To save your changes:

  1. Press Ctrl + O
  2. Hit Enter to confirm the filename

To exit nano:

  • Press Ctrl + X

If you made changes but forgot to save, nano will ask if you want to save before closing. That’s a nice safety net.


Deleting and Copying Text

Deleting is simple. Put your cursor where you want to delete and press Backspace.

If you want to remove a whole line:

  • Press Ctrl + K (this “cuts” the line)

To paste it somewhere else:

  • Move the cursor, then press Ctrl + U

This makes copying chunks of text easy, like cutting out a slice of cake and moving it to another plate. (Yum.)


Searching for Text

Ever been inside a big file and thought, “Where’s that setting again?”

Here’s the trick:

  • Press Ctrl + W to search
  • Type the word you want, then press Enter

If it doesn’t find the word, nano will tell you. And if it finds more than one match, press Ctrl + W again and hit Enter to go to the next one.

I use this when fixing broken web configs, usually when I forget a semicolon (oops).


Two Lists to Remember

Here are two helpful lists I keep in mind when using nano.

Common nano Shortcuts

  • Ctrl + O → Save file
  • Ctrl + X → Exit
  • Ctrl + K → Cut line
  • Ctrl + U → Paste line
  • Ctrl + W → Search
  • Ctrl + _ → Go to line number
  • Ctrl + C → Show current line and position
  • Alt + U → Undo last change
  • Alt + E → Redo

Things I Like About nano

  • Doesn’t require mouse or menus
  • Works inside SSH or any terminal
  • Shows shortcuts right on screen
  • Great for quick edits
  • Doesn’t have a steep learning curve
  • Tiny and fast

I’ll be honest, I still use other editors too. But nano is the one I trust when I need something simple and quick.


Editing Like an Expert (Without Being One)

Want to impress your future self? Here are a few cool things you can do in nano once you’re more confident:

1. Highlighting

If your version of nano supports syntax highlighting, it will color different parts of your file (like in code). This helps you spot errors fast.

Try it with:

nano ~/.bashrc

See the colors? That means nano is helping you read code faster.

2. Using Line Numbers

To show line numbers while editing, start nano like this:

nano -l filename.txt

That -l stands for “line numbers.” Helpful for debugging or when editing long files.

3. Backups

nano can make a backup before saving changes. Use the -B option:

nano -B config.txt

Now if something goes wrong, you’ve got a file called config.txt~ as backup. No tears.


Comparing nano to Other Editors

Let’s keep it real. There are a lot of editors out there. Why use nano?

Feature nano vim GUI editors like VS Code
Easy to learn ✅ Yes ❌ No ✅ Yes
Needs mouse ❌ No ❌ No ✅ Yes
Runs in terminal ✅ Yes ✅ Yes ❌ No
Pre-installed ✅ Most Linux ✅ Most Linux ❌ Usually not
Fancy features ❌ Few ✅ Tons ✅ Tons

So while vim is powerful, nano is easier. I see nano as a friendly tool that doesn’t try to outsmart me. Just open it, edit, save, done.


Real-Life Example

Let’s say you want to change your hostname. You might edit this file:

sudo nano /etc/hostname

Just type the new name, save it (Ctrl + O), and exit (Ctrl + X). Done.

You’ve just used nano to edit your Linux system like a pro.


A Little Bit of Fun

I once told a friend that nano was my “editor of choice.” He asked, “Is that because you’re too lazy to learn Vim?”

“Maybe,” I said, “but I like my text editors like I like my pizza—simple, fast, and not too many toppings.”

He laughed. And then he installed nano.


Final Thoughts

Using nano doesn’t make you less skilled—it makes you smart. It’s a lightweight, no-fuss editor that just gets the job done.

It’s great for:

  • Beginners who want to learn without stress
  • Server admins who need fast access
  • People who just want to fix things quickly

If you’re just starting out in Linux, or even if you’ve been around the block, nano deserves a spot in your toolkit.

So the next time you’re staring at a blank terminal, wondering how to edit a file, give nano a try. Your future self might just thank you—with a smile and a saved config file.

And remember: never underestimate a tool just because it’s small. Sometimes the tiniest tools do the mightiest work.

Now go forth and edit like a nano-ninja.

Leave a Reply