Skip to content

Block A: folder, nano, vim (1-6)

Task 01: practice folder

sudo mkdir -p /srv/linux-practice/{files,shared,backups}
sudo chown "$USER":"$USER" /srv/linux-practice/files /srv/linux-practice/backups
ls -ld /srv/linux-practice /srv/linux-practice/*

💡 /srv is a system location, so we need sudo. chown hands us only files and backups.

✅ The parent and shared belong to root; files and backups are yours.

Task 02: nano

nano /srv/linux-practice/files/app.conf

Write APP_NAME=shop, APP_ENV=dev, PORT=8080. Save with Ctrl+O, Enter; exit with Ctrl+X. Open it again.

Task 03: editing in vim

Action Keys
change a word cw, new text, Esc
new line at the end G, o
save and quit :wq

We changed the port to 9090 and added LOG_LEVEL=DEBUG, OWNER=training.

✅ cat -n shows 5 lines.

⚠️ Our line 4 became Go LOG_LEVEL=DEBUG: we had not pressed Esc, so the commands G, o were typed as text. Fix: Esc, 4G, 0, dw, :wq.

Task 04: delete and undo

5G (go to line), dd (delete line), u (undo), :q.

🔴 dd deletes, u brings it back.

Task 05: replace every word

files/notes.txt has 15 lines with test in five places.

:%s/test//gn            # count only
:%s/test/production/g   # replace
:wq
f=/srv/linux-practice/files/notes.txt; wc -l $f; grep -c test $f; grep -c production $f

✅ 15, 0, 5.

⚠️ On the first try we still got 5 and 0: the replacement was not saved. The check exposed it.

Task 06: quit without saving

cp /srv/linux-practice/files/app.conf /srv/linux-practice/backups/app.conf
vim /srv/linux-practice/files/app.conf     # change something, leave with :q!
diff /srv/linux-practice/files/app.conf /srv/linux-practice/backups/app.conf && echo "identical"

⚠️ On the first try the change was saved and diff showed 6d5 and < shop=broken. We restored from the copy with cp and repeated with :q!.

🔴 :wq saves, :q! throws the change away.