Lion Cipher Lab

Editing files from the terminal: nano and vim

Why it matters

Configuring almost anything on a Linux box means editing a text file that lives on that box — a service config, an SSH setting, a hosts entry. There's no window to click; you open the file, change a line, and save, right there in the terminal. nano makes that gentle because it prints its shortcuts on screen. vim matters because it is the editor you can count on being present on a stripped-down server or inside a container, so knowing four commands means you're never stranded on a machine you can't edit.

What you'll learn

Steps in this lab

  1. Why admins edit files right where they live
  2. Open a file in nano — and read the bar at the bottom
  3. Save with Ctrl+O, leave with Ctrl+X
  4. Why bother with vim: it's the editor that's always there
  5. Press i to insert, Esc to stop
  6. Save and quit with :wq — or bail out with :q!
  7. Which one when — and confirm your edits stuck
  8. You can edit any config now — here's what that unlocks

Open the full interactive lab →