Editing files: nano and a first step into vim
You create a file and change a setting with nano; you learn vi’s modes (normal, insert, command), quit without saving, search and delete a line, replace across the whole file and verify your changes with diff; at the end you bring a service config to the shape the security team wants and add a logon warning banner. The setting values differ in every lab.
Level 101 · 45 min
Servers have no graphical interface; config files are edited in the terminal. Daniel asks you to harden the dispatch service’s settings; but first you need to get to know two editors.
nano is simple: you open it and type; the shortcuts are written at the bottom of the screen (^ means Ctrl): Ctrl+O save, Ctrl+X exit, Ctrl+W search. vi (vim) exists on every Linux and is very powerful but has modes: when it opens it is in normal mode (keys are commands), i switches to insert mode to type, Esc goes back to normal, : opens the command line (:w save, :q quit, :wq save and quit, :q! quit without saving). The figures sum up the two editors.
It happens to everyone once: not knowing how to leave vi. The answer: Esc, then :q! and Enter.
What you will do in this lesson
- A first file with nano
- Change a setting with nano
- vi: insert mode and :wq
- Quit without saving: :q!
- Search and delete a line: / and dd
- Replace across the file: :%s
- Verify the changes: diff
- Harden the config
- The logon banner
- Short quiz
Skills you will earn
- Editing files with nano
- Editing a config file safely
- vi modes and saving and quitting
- Searching, deleting and replacing in vi
- Reading the difference between two files (diff)
← Aliases, command substitution and history · Linux fundamentals · Short task: build a daily summary with a one-liner →
Start for free