Introduction to Nano: Your First Terminal Text Editor
Master file editing in the terminal with Nano. Learn how to open, modify, and save configuration files for your web server project using this essential tool.

Previously in this course, we covered creating and removing files using commands like touch and rm. While those commands are perfect for managing file existence, they don't help you modify the contents inside those files. Today, we add the ability to actually write and edit data using Nano, the standard beginner-friendly text editor for the terminal.
Why Nano?
In the Linux ecosystem, you'll encounter two primary camps of terminal editors: "Simple" (like Nano) and "Power-user" (like Vim or Emacs). As a developer, you need to be comfortable in both environments. Nano is the "what you see is what you get" editor; it displays a cheat sheet at the bottom of the screen, making it the perfect starting point before we tackle more complex tools in the next lesson.
Opening and Editing Files
To open a file in Nano, you simply pass the filename as an argument to the nano command. If the file exists, it opens for editing; if it doesn't exist, Nano creates a new buffer for that filename, which will be saved once you write the file to disk.
Open your terminal and try opening a new file for our project:
Bashnano web-config.txt
Once the editor opens, you are in "Edit Mode" by default. You can move your cursor using your arrow keys and type text just like you would in a GUI editor like Notepad or TextEdit.
Saving Changes and Exiting
The most important part of using a terminal editor is knowing how to leave it. Nano uses "Control" key combinations (often denoted as ^ in the documentation) to trigger commands.
Look at the footer of your Nano window. You will see a list of commands:
^O(Write Out): Saves the file.^X(Exit): Closes the editor.
The Workflow:
- Make your edits.
- Press
Ctrl + Oto start the save process. - Nano will prompt you: "File Name to Write: web-config.txt". Press
Enterto confirm. - Press
Ctrl + Xto exit back to your shell prompt.
Hands-on Exercise
Let's advance our web server project by creating a placeholder configuration file.
- Navigate to your project directory (refer back to navigating the file system if you've forgotten where it is).
- Open a new file named
server.confusingnano server.conf. - Type the following two lines:
TEXT
port=80 server_name=localhost - Save the file (
Ctrl + O, thenEnter). - Exit the editor (
Ctrl + X). - Verify the file content by using
cat server.confin your terminal.
Common Pitfalls
- The "Frozen" Terminal: Sometimes, users accidentally press
Ctrl + S. In many terminal emulators, this sends an XOFF signal, which pauses terminal output. If your screen stops responding, pressCtrl + Qto resume. - Saving Errors: If you try to edit a system file (like something in
/etc/), Nano will tell you that the file is not writable. Always ensure you have the correct permissions before trying to save; if you don't, you will need to open the file withsudo nano filename. - Muscle Memory: Don't get too comfortable with the mouse inside Nano. While some terminal emulators allow mouse clicking to move the cursor, it is inconsistent across servers. Stick to your arrow keys to build reliable habits.
FAQ
Q: Can I use my mouse in Nano? A: Most modern terminal emulators support mouse interaction, but it is better to practice using the arrow keys to ensure you can edit files on remote servers where mouse support might be disabled.
Q: What if I make a mistake and want to exit without saving?
A: Press Ctrl + X. Nano will ask if you want to save the modified buffer. Press n for "No," and it will exit without applying your changes.
Q: Is Nano installed on every Linux system?
A: Almost every distribution includes it by default. If you ever find yourself on a "minimal" image where it isn't, you can usually install it via your package manager (e.g., sudo apt install nano).
Recap
In this lesson, we moved beyond just creating files to actually modifying their contents. You learned that nano is your go-to tool for quick, reliable edits in the terminal, how to save your work with Ctrl + O, and how to exit safely with Ctrl + X. These skills are essential for the upcoming tasks where we will configure real server software.
Up next: We will level up our skills by tackling Vim, the industry-standard editor you'll find on virtually every Unix-like system.
Work with me

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.

Next.js E-commerce Store Development
Turn your Facebook page or small shop into a real online store — fast, mobile-first, and built to sell. Own your storefront, not just a social page.


