Skip to content
Clairos Learn

Networking · Lesson 10 of 26 · 8 minutes

Port inventory text

Normalize and count port inventory text.

Mastery 0/3Run itExplain itApply it
learner@clairosSimulated Linux lab
learner@clairos:~ $
↑ history · Tab complete · Ctrl+C cancel · Esc, Tab to leaveExit 0

Understand the pattern

Junior operators build confidence by gathering evidence before changing systems.

cat
Read one or more files to standard output without editing their contents.

Reading a source file should precede changing it; avoid printing real secrets.

sort
Order lines before comparing or grouping them; -n compares numerically and -r reverses order.

Alphabetical sorting is not numeric sorting.

uniq
Collapse adjacent duplicate lines; use sort first when duplicates are not already together.

uniq does not find every duplicate in an unsorted stream.

wc
Count input. -l counts newline characters, -w counts whitespace-delimited words, and -c counts bytes.

Text without a final newline may have fewer counted lines than visible rows.

tail
Show the end of an input; -n selects the number of lines.

This browser lab snapshots output; it does not keep a live tail -f stream.

Worked example and expected result
$ cat data/ports.txt | sort | uniq
22
23
443
80

Exit status: 0. The command completed successfully in the training fixture.

$ wc -l data/ports.txt
5 data/ports.txt

Exit status: 0. The command completed successfully in the training fixture.

$ tail -n 3 data/ports.txt
443
23
22

Exit status: 0. The command completed successfully in the training fixture.

Try a variation

Repeat this workflow in the sandbox with a different scratch filename. Keep the system fixtures unchanged and compare the observed output with your expectation before moving on.

Explain it

In “Port inventory text”, which interpretation is safe?

Apply it elsewhere

Before adapting the wc workflow from “Port inventory text” to another server, what should you do?

Keep the momentum.

Complete the lab, then explain and apply the pattern.

Next: Network log grepTry an incident drill

Anonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.

Keep learning

  1. 01Firewall service matchCompare firewall rules with service listeners.Practice
  2. 02Network log grepSearch logs for link and access clues.Practice
  3. 03Interface baselineRecord a basic network baseline.Practice