This 3‑hour workshop introduces the most common Linux utilities for inspecting and modifying files. It is ideal for students who already know how to navigate a filesystem but need to learn how to read, search, and edit text data in a console‑only environment.
cat, less, more, head, and tail.grep and regular expressions.sed and awk.nano) and advanced (vim) editors.diff and comm.cat, less, morehead, tailgrepsedawknano and vimdiff, commcat – Concatenate & DisplayDisplays the entire contents of a file on standard output.
cat README.md
Combine multiple files:
cat file1.txt file2.txt > merged.txt
hello.txt with the text “Hello World” and display it with cat.hello.txt and world.txt into greeting.txt.less – Page‑wise ViewerAllows forward/backward navigation through large files.
less /var/log/syslog
Search inside the file:
/error
greeting.txt with less and search for the word “Hello”.F key to tail the file live.more – Simple PagerOlder, less feature‑rich pager. Good for quick one‑page look.
more greeting.txt
more and navigate using Space and b.head – Show First LinesPrints the first 10 lines by default.
head /etc/passwd
Custom line count:
head -n 20 /etc/passwd
/etc/hosts.head -c 100 to display the first 100 bytes.tail – Show Last LinesPrints the last 10 lines by default.
tail /var/log/kern.log
Follow a file in real‑time:
tail -f /var/log/syslog
greeting.txt.syslog for 10 seconds, then exit.grep – Pattern SearchFinds lines matching a pattern (regular expression).
grep -i "error" /var/log/syslog
Recursive search:
grep -r "TODO" .
/etc/passwd.-n.sed – Stream EditorPerforms in‑place or streamed transformations.
sed 's/foo/bar/g' file.txt
Delete lines:
sed '/^#/d' file.txt
greeting.txt and show the result.#) from a script file.-i to edit the file in place.awk – Field ProcessorProcesses text line‑by‑line using fields.
awk -F: '{print $1,$3}' /etc/passwd
Sum a column:
awk '{sum += $1} END{print sum}' numbers.txt
/etc/passwd.filesizes.txt.nano – Simple Text EditorKeyboard‑friendly editor for quick edits.
nano /etc/hostname
Save with Ctrl+O, exit with Ctrl+X.
greeting.txt with nano, add a new line, and save.vim – Powerful Text EditorModal editor with extensive features.
vim /etc/hosts
Insert mode: i, save: :w, quit: :q, save & quit: :wq.
hosts and save.diff – Compare FilesShows line‑by‑line differences.
diff old.txt new.txt
Unified format:
diff -u old.txt new.txt
greeting.txt and identify the changes.changes.patch.comm – Compare Sorted FilesRequires sorted input; outputs three columns: unique to file1, unique to file2, common.
comm file1.txt file2.txt
comm -12 file1.txt file2.txt # common lines only
list1.txt and list2.txt then use comm to find common items.Students will work in pairs to complete the exercises above. The instructor circulates to provide guidance and ensure that the “safety first” mindset is reinforced:
cat or less before editing.sed -i or awk with caution; keep backups.shellcheck for shell scripts)..log files.grep and wc -l.Feel free to adapt the schedule or exercises to suit your students’ skill level or time constraints.