Linux Basic/Linux Self Assessment
Linux Basics — Self-Assessment
This page lets you verify that you have mastered the material from the Linux Basics Course. Work through the parts in order on Anunna. The final challenge produces a report file that proves you completed every step — submit (or keep) that file as evidence.
Prerequisites: an Anunna account and the course data at /lustre/shared/hpcCourses/shell-lesson-data.zip.
Rules:
- Do everything from the command line. No file-manager GUIs, no OnDemand file browser (the shell is fine).
- If you get stuck, refer back to the course slides, use
man,--help, or the Software Carpentry shell course — that is part of the skill.
Part 1 — Connect and orient
- Connect to Anunna via SSH.
- Confirm where you are with
pwd. You should be in your home directory (/home/WUR/yourusername).
Part 2 — Build the workspace (directories and navigation)
- In your home directory, create this directory tree with a single command:
~/linux_test/
- ├── data/
- ├── scripts/
- └── results/
- Hint: one
mkdirflag makes parent directories for you.
- Change into
~/linux_test/datausing a relative path from your home directory. - Go back to your home directory using only
cdshortcuts (no full paths).
Part 3 — Work with files
- Copy the course archive into your home directory and extract it:
cp /lustre/shared/hpcCourses/shell-lesson-data.zip ~/ unzip ~/shell-lesson-data.zip -d ~/
- Find the file
unicorn.datinside the extracted data and copy it to~/linux_test/data/sample.dat. - Inside
~/linux_test/data, create 12 empty files namedrun_01.logthroughrun_12.logwith a single command (brace ranges). - Delete only the even-numbered log files using wildcards/ranges — in as few commands as you can. Check with
lsthat exactly 6 odd-numbered files remain.
Part 4 — Pipes, filters, redirects
- Count how many lines in
sample.datcontain the patternTACCGGACAA, usinggreppiped intowc. - Redirect that number into
~/linux_test/results/pattern_count.txt(it should contain a single number, nothing else).
Part 5 — Environment variables
- Create an environment variable holding your full name and export it:
export REPORT_AUTHOR="Your Name"
- Verify it exists with
echo $REPORT_AUTHORand find it in the output ofenv. - Question to yourself: why is
exportneeded here? You will find out in the final challenge — your script runs as a child process, and only exported variables reach it.
Part 6 — Final challenge: the report script
Using a command-line text editor (nano is what the course taught, but vim or emacs are equally fine), create the file ~/linux_test/scripts/generate_report.sh with exactly this behaviour. Write it yourself — the skeleton below shows the required output labels, you fill in the commands.
The script must:
- start with the correct interpreter header for bash,
- write all output to
~/linux_test/results/report.txt(overwriting any previous report), - produce one labelled line per check, in this order:
| Label | Content | What it proves |
|---|---|---|
USER: |
output of whoami |
you ran it yourself |
DATE: |
output of date |
when |
AUTHOR: |
value of $REPORT_AUTHOR |
you understand export
|
SHEBANG: |
first line of the script itself (head -n 1 "$0") |
interpreter header present |
PERMS: |
permission octal of the script itself (stat -c '%a' "$0") |
you made it executable |
LOGFILES: |
number of .log files in ~/linux_test/data |
Part 3 globbing done |
PATTERN: |
contents of ~/linux_test/results/pattern_count.txt |
Part 4 done |
A starting skeleton (the first two lines are done for you):
#!/bin/bash
REPORT=~/linux_test/results/report.txt
echo "USER: $(whoami)" > "$REPORT"
echo "DATE: $(date)" >> "$REPORT"
# ... your turn: AUTHOR, SHEBANG, PERMS, LOGFILES, PATTERN ...
Mind the difference between > and >> — only the first line should overwrite.
Run it
- Make the script executable for yourself with
chmod. - Change into
~/linux_test/scriptsand run it with a relative path:cd ~/linux_test/scripts ./generate_report.sh
- Run it once more from your home directory using the full path. Both must work.
- Bonus question: why does plain
generate_report.sh(no./) fail? Which environment variable is responsible?
Check yourself
Display the report:
cat ~/linux_test/results/report.txt
You pass if all of the following hold:
AUTHOR:shows your name (not empty — if it is empty, you forgotexport);SHEBANG:shows#!/bin/bash;PERMS:starts with a7(e.g.744,755) — owner has read, write and execute;LOGFILES:is6;PATTERN:is a number greater than0.
If any line is wrong, fix the corresponding part and re-run the script — that is the whole point of scripts.
For instructors
A submitted report.txt is verifiable at a glance, or in bulk:
grep -E '^(AUTHOR: .+|SHEBANG: #!/bin/bash|PERMS: 7..|LOGFILES: 6|PATTERN: [1-9])' report.txt | wc -l
# Expect: 5
Asking students to also submit the script itself catches copy-pasted reports: the SHEBANG: and PERMS: lines must be consistent with the actual file.