10. Introduction to Text Editors: Using nano
To write scripts, configure files, and code, you need a powerful text editor. Termux comes pre-installed with nano, a beginner-friendly editor.
Launching nano
To edit a file, simply type nano followed by the filename. If the file doesn't exist, nano will create it.
bash $ nano my_config.txt
The nano Interface
Once inside nano, you will see your file content, and the bottom two lines display helpful shortcuts.
- The
^symbol represents the Ctrl key (which you access via the Termux extra keys row).
| Shortcut | Action |
|---|---|
^G (Ctrl+G) | Get Help |
^X (Ctrl+X) | Exit the editor |
^O (Ctrl+O) | Write Out (Save changes) |
^W (Ctrl+W) | Where is? (Search) |
Basic Editing Workflow
- Open/Create:
nano script.sh - Type Content: Enter your code or text.
- Save: Press
Ctrl + O.nanowill ask you to confirm the filename. Press Enter. - Exit: Press
Ctrl + X.
Practice: Use nano to create a file named hello.txt containing the text "Hello, Termux world!" and save it.