Lesson 8.1: Editing files with nano
Why you need a terminal text editor, the parts of the nano screen, creating and saving a file (^O), leaving (^X), cutting and pasting lines (^K, ^U), search and replace (^W, ^\), what happens when you open a file you may not change, and editing a system file with sudo nano.
18 min
You will learn to
- Read nano's screen: title bar, text, status line, shortcut list
- Create, save and leave a file
- Cut and paste whole lines
- Search and replace text
- Recognise the 'unwritable' warning and edit system files with sudo nano
Key terms
- Text editor
- A program for changing plain text files. Terminal editors run full-screen inside the terminal and are driven entirely by the keyboard.
- GNU nano
- A small, beginner-friendly terminal editor. The most important shortcuts are always listed at the bottom of the screen.
- ^ and M- notation
- ^X means Ctrl+X. M-U means Meta+U, which is Alt+U on a PC keyboard (or Esc then U).
- Buffer
- The copy of the file in the editor's memory. You change the buffer; the file on disk changes only when you save (write out).
- Cutbuffer
- nano's clipboard. ^K cuts the current line into it (several ^K in a row collect several lines); ^U pastes it at the cursor.
← Converting text files: line endings and encodings · All lessons · Vim basics: modes, saving and quitting →