ls lists names in a folder. An option changes its behavior: -a includes names beginning with a dot. These often hold configuration. Combine -a with -l to see a detailed listing.
ls -a
ls → list names · -a → include hidden entries
YOUR UNIX TASK
List your home directory, including the hidden .notes file.
Hint 1. Try ls first, then add the option that shows all entries.
cd changes the current directory. A relative path starts in your current folder; an absolute path starts at /. Use .. for the parent, ~ for home, and cd - to return to the previous directory.
cd projects
cd → change directory · projects → folder to enter
YOUR UNIX TASK
Navigate into the website folder inside projects.
Hint 1. You can enter both folders in one path, separated by /.
cat writes a file’s contents to standard output: usually your terminal. It can also combine multiple files. Each lesson starts with a fresh practice filesystem in your home directory.
cat welcome.txt
cat → print contents · welcome.txt → input file
YOUR UNIX TASK
Display the complete contents of welcome.txt.
Hint 1. Use cat followed by the file’s name.
Hint 2. Run cat welcome.txt from the home directory.
grep keeps lines containing a pattern. By default, case matters: ERROR and error differ. Add -i to ignore case. This simulator teaches literal searches; full regular expressions are a later topic.
A pipe, |, passes one command’s standard output to the next command’s standard input. wc -l counts newline characters. Combine it with a filter to count matching lines.
cat welcome.txt | wc -l
cat → produce text · | → pass it along · wc -l → count lines
YOUR UNIX TASK
Use a pipeline to count all error lines in logs/app.log, ignoring case. The result should be 3.
Hint 1. Start with the case-insensitive error search from the previous lesson.
Hint 2. Pipe grep -i error logs/app.log into wc -l.
sort puts lines in order. uniq removes adjacent duplicates, so sort first when repeated values are scattered. sort -u is a useful shortcut. The practice shell uses a fixed character order; real sorting depends on locale.
Plain sort compares characters, which can place 12 before 3. Add -n to compare numeric values. Add -r to reverse the ordering, and put the largest values first.
sort -n data/scores.txt
sort → order lines · -n → compare as numbers
YOUR UNIX TASK
Print data/scores.txt from highest score to lowest.
Hint 1. You need both numeric sorting and reverse order.
The > operator writes standard output to a file, creating it if needed and replacing any existing contents. The terminal stays quiet because output went to the file. Use cat to inspect the result.
echo "My first note" > note.txt
echo → produce text · > → write to a file · note.txt → destination
YOUR UNIX TASK
Write the text Hello terminal to a file named greeting.txt in your home directory.
Hint 1. echo prints text; > sends that text to a file.
While > replaces contents, >> adds output to the end of a file. Quotes keep multiple words together. Newlines come from the command producing the output, not from the redirection operator.
echo "Another line" >> note.txt
>> → append output, preserving existing content
YOUR UNIX TASK
Create notes.txt with First step on the first line and Keep going on the second. Use >> to add the second line.
Hint 1. First use > to write First step, then >> to add Keep going.
Hint 2. Run echo "First step" > notes.txt, then echo "Keep going" >> notes.txt.
find walks a directory tree. -type f selects files, and -name matches names. Quote a wildcard pattern so the real shell passes it to find instead of expanding it first.
find . -type f -name "*.txt"
. → current folder · -type f → files · -name → name pattern
YOUR UNIX TASK
Find README.md anywhere inside the projects directory.
Hint 1. Start the search at projects and use -name to select README.md.
Filter the log, normalize its order, remove repeated lines, and save the result. Commands compose because they share a simple interface: text in, text out.
producer | filter | sort > report.txt
This is a pattern, not a runnable command. Choose the tools you have learned.
YOUR UNIX TASK
Save all error lines from logs/app.log, ignoring case, sorted with duplicates removed, to errors.txt in your home directory.
Hint 1. Begin with grep -i error logs/app.log.
Hint 2. Pipe the results to sort -u and redirect into errors.txt.
A second grep narrows the first result. grep -v excludes matching lines. Inspect the input before choosing filters; a match is text evidence, not proof of a root cause.
grep -i error logs/service.log | grep api
Each stage keeps only the lines that satisfy its filter.
YOUR UNIX TASK
Read logs/service.log. Save every API error, ignoring case, in original order to api-errors.txt. Save the number of those lines to error-count.txt (number only).
Hint 1. Build the filtered file first, then pipe its contents to wc -l.
uniq compares neighboring lines. sort brings equal IDs together; uniq -c counts each group and uniq -d keeps only repeated groups. Counting raw, unsorted input can miss repeats.
sort data/jobs.txt | uniq -c
Counts describe occurrences, including the first copy.
YOUR UNIX TASK
Save only the repeated job IDs, once each and alphabetically, to repeated.txt. Save counts for every ID, alphabetically by ID, to frequencies.txt.
Hint 1. Both reports begin with sorted input. Consult man uniq for the two options.
comm compares two sorted files. Its three columns contain lines unique to the first file, unique to the second, and shared by both. -23 suppresses columns two and three; -13 leaves only column two. Sort and deduplicate both inventories first.
comm -23 before-sorted.txt after-sorted.txt
Keep entries that exist only in the first inventory.
YOUR UNIX TASK
Compare data/before.txt and data/after.txt. Save removed services to removed.txt and added services to added.txt, each alphabetically and without duplicates.
Hint 1. Create two sorted unique scratch files, then compare in both directions.
mkdir creates a destination folder. cp copies a file; mv relocates or renames it. Quote names containing spaces. This simulator supports one file at a time and rejects existing destinations to prevent accidental overwrites; real cp and mv can overwrite files.
cp "inbox/project brief.txt" delivery/brief.txt
Copy the source to a deliberately named destination.
YOUR UNIX TASK
Create delivery. Copy inbox/project brief.txt to delivery/brief.txt, retaining the original. Move inbox/results.txt to delivery/results.txt. Leave inbox/scratch.txt untouched. Save a sorted list of file paths under delivery to manifest.txt.
Hint 1. Create the folder before copying or moving. Use find to build the manifest.
cut -d chooses a one-character delimiter; -f selects a field, numbered from one. This exercise uses simple pipe-delimited records, not quoted CSV. Extract service names, count them, then sort counts numerically in descending order.
cut -d "|" -f 2 data/requests.txt
Each row is request ID | service | outcome, with no header.
YOUR UNIX TASK
Save counts per service to service-report.txt, highest count first. Include successful and failed requests. Preserve the input file.
Hint 1. Extract field two, sort it, count groups, then sort the counts numerically.
The logs use comparable, zero-padded timestamps and request IDs. A timeline requires matching the same request across files and ordering all of its events. A nearby failure from another request may be unrelated. Read the evidence before naming the cause.
cat logs/gateway.log logs/database.log
Combine sources before filtering and ordering.
YOUR UNIX TASK
Investigate request req-42. Save all its events from both logs chronologically to timeline.txt. Then save just its ERROR events to incident-errors.txt. Write the failing dependency name (database) to dependency.txt after reviewing the timeline.
Hint 1. The request ID connects the files. Keep context events in the timeline, then derive the error-only report.
Read data/rules.txt first. These fixtures use a deliberately narrow rule: rows containing |active| are eligible unless the address is MISSING. Field three holds the address. This is a structured exercise, not a general email validator. Keep rejected records instead of silently dropping them. Use grep -F for literal punctuation such as the pipe delimiter.
cat data/rules.txt
Discover the acceptance rule before writing the pipeline.
YOUR UNIX TASK
Save unique eligible addresses alphabetically to recipients.txt. Save all rejected rows to rejected.txt in alphabetical order. Keep data/members.txt unchanged.
Hint 1. Separate inactive rows from active rows with missing addresses; combine those rejection groups before sorting.
A shell script is a text file of commands. Single quotes around an echo argument store pipes and redirection literally. sh report.sh reads and runs those commands. Our bounded runner supports up to 20 simple command lines, comments, and pipelines; variables, arguments, loops, and nested scripts are outside this exercise. It stops on errors, unlike a default real sh script.
The outer > writes the script. The quoted > is executed later by sh.
YOUR UNIX TASK
Create report.sh in your home folder. It must generate script-errors.txt from all error lines in logs/service.log, ignoring case, sorted and deduplicated. Run sh report.sh. Your script must generate a fresh report when the log contents change.
Hint 1. Store the working filter-and-sort pipeline inside single quotes, then execute the saved file.
A pipeline can run successfully and still answer the wrong question. Read the supplied broken command. Check which lines survive filtering, whether repeats are adjacent when counted, and whether the final sort uses numbers in the intended direction.
cat broken-pipeline.txt
Read the attempted workflow, then inspect stages in isolation.
YOUR UNIX TASK
Repair the pipeline described in broken-pipeline.txt. Save the two most frequent error messages and their counts to top-errors.txt, highest count first. Match ERROR and error. Count the message field (field three), not the whole record.
Hint 1. There are three logic mistakes: case-sensitive filtering, counting before grouping, and ascending numeric sorting.
Related tool: displays a file one screen at a time. CMD has no simple built-in head equivalent that selects exactly the first two lines; use the PowerShell example.
Case-insensitive by default. -SimpleMatch treats the pattern as literal text. Results are MatchInfo objects containing the matching line, file, and line number.
On Windows versions supporting /unique, sort can remove duplicates. Check sort /? on the target machine; PowerShell provides the more portable Windows approach.
Related tool: /r reverses text order, but CMD sort has no numeric-sort option. It does not solve this numeric task. Use PowerShell to compare values as numbers.
Writes the line to a file and replaces existing contents. Redirection is placed first to avoid an accidental trailing space in the message. CMD echo would print surrounding quotation marks.
Filters, sorts, removes duplicates, and saves text. Requires a sort version supporting /unique. Windows sort ordering and case handling can differ from the Unix exercise.
Extracts the Line property before sorting and writing. -CaseSensitive preserves differences between differently cased lines. Culture-based ordering can still differ from Unix.
Related technique, not a complete solution to this project. /i ignores case; /l uses literal matching; /c: keeps the search text together. CMD’s findstr options use slashes.
Related technique, not a complete solution to this project. Case-insensitive by default. -SimpleMatch treats the pattern as literal text. Results are MatchInfo objects containing the matching line, file, and line number.
Related first step: produce a unique job inventory. This does not select only repeated jobs or count occurrences. On Windows versions supporting /unique, sort can remove duplicates. Check sort /? on the target machine; PowerShell provides the more portable Windows approach.
Get-Content .\data\jobs.txt | Group-Object -NoElement | Sort-Object Name
Groups matching IDs and reports their counts, even when repeats are not adjacent. Unlike uniq, input need not be sorted first. This is the frequency report step.
Preparation step: sort and deduplicate the first release inventory before comparing. On Windows versions supporting /unique, sort can remove duplicates. Check sort /? on the target machine; PowerShell provides the more portable Windows approach.
<= marks entries only in the reference (removed); => marks entries only in the difference set (added). Outputs objects rather than comm’s text columns.
The delivery directory must already exist. Moves the results file; the copy and manifest steps are separate. CMD can prompt before overwriting an existing target.
Inspection step only: read the source before constructing a report. The PowerShell example demonstrates grouping and numeric counts; CMD type does not aggregate records.
Extracts the service with a zero-based array index, groups it, and sorts numeric Count properties. Displays a table; saving a report is a separate step.
Related technique, not a complete solution to this project. /i ignores case; /l uses literal matching; /c: keeps the search text together. CMD’s findstr options use slashes.
Related technique, not a complete solution to this project. Case-insensitive by default. -SimpleMatch treats the pattern as literal text. Results are MatchInfo objects containing the matching line, file, and line number.
Eligibility filter only; missing addresses still need to be excluded. /i ignores case; /l uses literal matching; /c: keeps the search text together. CMD’s findstr options use slashes.
Eligibility filter only; missing addresses still need to be excluded. Case-insensitive by default. -SimpleMatch treats the pattern as literal text. Results are MatchInfo objects containing the matching line, file, and line number.
Inspect the saved Unix script as text. This does not execute it. CMD batch files and PowerShell scripts use different syntax; this Unix script needs a compatible Unix shell.
Inspect the saved Unix script as text. This does not execute it. CMD batch files and PowerShell scripts use different syntax; this Unix script needs a compatible Unix shell.
Inspection step only: read the source before constructing a report. The PowerShell example demonstrates grouping and numeric counts; CMD type does not aggregate records.
Select-String ignores case by default. Extracts the message, groups occurrences, then selects the two highest counts. Displays objects; this does not write top-errors.txt.