Introduction
So far, we have only read files. Now, it is time to write them.
In Linux, the simplest editor is called nano.
Nano is the "Notepad" of the Linux terminal. It is simple, friendly, and runs right inside your command window. It doesn't have menus you can click with a mouse, but it is easy to control with your keyboard.
For beginners, this matters because many server environments do not offer a graphical editor at all. A terminal editor is not an optional extra in Linux administration; it is often the direct way to fix configuration or create small files on a remote machine.
In this lab, you will write your first file, save it, and exit—the "Hello World" of text editing.
Open File
To write a file, you simply tell nano the name of the file you want to create (or edit).
Let's create my_file.txt.
Run this command:
nano my_file.txt
Your terminal screen will change. You have entered the editor!
This is another example of stepping from the shell into a different program. While Nano is open, your keyboard input goes to the editor, not to the shell prompt.
- The big empty space is where you type.
- The bottom shows a "cheat sheet" of shortcuts.
Note: The caret symbol ^ means the Ctrl key. So ^X means Ctrl+X.
This notation appears in many terminal tools, so learning it once will help you read on-screen shortcut hints elsewhere too.
Edit Text
Adding text in Nano is easy: just type!
That simplicity is exactly why Nano is such a common beginner editor. It behaves much more like a regular text box than modal editors do.
Type this message:
Hello, LabEx!
This is my first file using nano.
Using the Cursor:
- Use the Arrow Keys to move.
- Do NOT use the mouse. Clicking usually does not work in terminal editors.
Save Changes
In Nano, saving is called "Writing Out" (^O).
To save your file:
- Press Ctrl+O.
- Nano will ask to confirm the filename. Press Enter.
Nano will say [ Wrote 2 lines ]. Your file is safe!
The word write appears often in Unix editing culture as a synonym for saving changes to disk. That is why the save command in Nano is described as "Write Out."
Exit Editor
Now let's leave the editor.
The shortcut for Exit is ^X.
Press Ctrl+X.
Since you already saved, Nano will close immediately, and you will see your command prompt again.
Verify your work using cat:
cat my_file.txt
You should see your message: Hello, LabEx!
Summary
You have mastered the Nano cycle:
nano filename: Open.- Type & Edit: Write.
- Ctrl+O + Enter: Save (Write Out).
- Ctrl+X: Exit.
It might feel clunky compared to a mouse-driven editor, but this skill allows you to fix servers from halfway across the world using just a keyboard!



