Touch created an empty file. Nano lets us put text inside it without leaving the terminal. We will open a file, write two lines, save and exit; there is no need to memorize every shortcut at once.
Open the file
cd "$HOME/netopsiyon-dersleri"
nano notlar.txt
The directory comes from the preceding lessons. Nano shows a filename near the top, an editing area and shortcuts below. You are no longer at a shell prompt. Typing exit would put that word into the file rather than close the editor.
Enter these two lines:
Ilk Linux notum.
Dosya ve dizin arasindaki farki ogreniyorum.
The text says you are learning the difference between files and directories. The sample uses ASCII characters for easy comparison across terminal encodings. A UTF-8 terminal and file can also contain normal Turkish characters.
Save with Ctrl+O and leave with Ctrl+X
The caret in ^O means Ctrl; do not type a literal caret followed by O. Hold Ctrl and press O. At the filename prompt, keep notlar.txt and press Enter. Check the written-file notification.
Ctrl+X exits to the shell prompt. Saving and leaving are separate operations: Ctrl+O writes the file but keeps the editor open. Reopen it and verify that both lines remain.
Discard a new change
Add a third line and press Ctrl+X without saving first. Nano asks whether to save the modified buffer. Use the No key shown on your screen; the letter can depend on the interface language. This discards changes since the last save, not the two lines already written to disk.
Reopen the file to confirm the third line is absent. If uncertain at the save question, cancel and return to editing before making a decision.
The editing buffer is not yet the disk file
Nano holds editable text in a buffer. Typing changes that buffer; saving writes it to disk. A file-size check in another terminal need not change after each keystroke. This distinction explains the save questions.
Opening a nonexistent filename can create a new buffer without immediately creating a disk file. If you leave without saving, no file may have been created. Read the status line and the write confirmation instead of assuming that opening equals creation.
Saving under a different name
At the Ctrl+O filename prompt, you can enter notlar-yeni.txt. That is not the same as renaming the old disk file with mv: the original can remain. Inspect both names and reopen them to see which content each holds.
A filename can include a directory path, but its parent directory must exist and be writable. Repeatedly pressing Enter does not repair an invalid path or missing permission.
Cut a line, then paste it
In the default nano bindings, Ctrl+K cuts the current line and Ctrl+U pastes the cut text. Cutting is not copying: the line disappears from its old position. Practice only on the lesson file.
Move the cursor before pasting and observe the new order. Leaving without saving can abandon a mistake, but also abandons all other changes since the last save. That is different from undoing just one action.
Open a particular line
nano +2 notlar.txt
The plus-prefixed number selects the starting line. It does not remove the earlier text. This is useful when a diagnostic message points to a location in a long file.
Use the Search shortcut shown by your installed nano, consulting Ctrl+G help if necessary. Search moves within text; Replace can actually change it. Do not confuse the two during your first experiment.
Move a line, save and reopen to verify persistence. Then change a character and leave without saving. Reopening should show the previous saved character. These two experiments separate buffer edits from disk contents.
If nano is missing
nano --version
A command-not-found error may mean the editor is not installed. In our Ubuntu environment, an authorized account can use:
sudo apt update
sudo apt install nano
These refresh package information and install the editor; they are not file-editing operations. Other distributions may require a different package manager.
Ctrl+G opens help. Some search shortcuts differ between nano versions, so read the labels on your actual screen. Finish by reopening notlar.txt and checking the two saved lines: the next lesson needs a file with real content to copy.
References: GNU / Linux