Lesson  in  Linux for SRE / DevOps - Beginner Level

Editing Configs Over SSH

on Linux
cat/less/head/tail -f, nano, and just enough vim to survive - reading and fixing a file with no GUI editor available.

Reading, without editing

You don't always need an editor - often you just need to look:

cat notify.conf              # dump the whole file
less notify.conf              # scroll through it, q to quit
head -n 5 notify.conf           # first 5 lines
tail -n 5 notify.conf            # last 5 lines
tail -f app.log                   # follow a growing log file live, Ctrl-C to stop
$ cat notify.conf
# Notification service config
retry_count = 1
timeout_seconds = 2
queue_name = notify-prod

tail -f is the single most-used command during an actual incident - watching a log file update in real time as things happen, rather than re-running cat over and over to see if anything new arrived.

nano - the gentle one

nano notify.conf

Arrow keys move the cursor, typing inserts text, Backspace deletes. The shortcuts are listed along the bottom of the screen the whole time. Ctrl+O then Enter saves, Ctrl+X exits.

vim - the one that's always there

Every server you will ever touch has vim (or at least vi). Not every server has nano. It's worth knowing the four moves that get you in, editing, and back out again:

  1. vim notify.conf opens in normal mode - keystrokes are commands, not text
  2. Press i to enter insert mode (you'll see -- INSERT -- at the bottom) - now you can type normally
  3. Press Escape to leave insert mode and go back to normal mode
  4. In normal mode, type :wq and Enter to save and quit

If you ever get stuck: Escape, then :q! and Enter abandons every change and gets you out. Nobody is ever permanently trapped in vim.

Fix it

~/notify-svc/notify.conf has one wrong value. Change retry_count from 1 to 5 - and leave every other line, queue_name included, exactly as it is. Whichever editor you pick, the file should read like this afterward:

# Notification service config
retry_count = 5
timeout_seconds = 2
queue_name = notify-prod

Only the one digit changed. Everything else - the comment, the other two values, the line order - matches the original exactly. That's the actual skill: a config edit that changes precisely what was asked and nothing else.

I'm not sure my vim change actually saved

Run cat notify.conf afterward and read it. If retry_count still says 1, you either never entered insert mode before typing, or you quit with :q! instead of :wq.