Journey: Linux commands
After this journey you can: navigate the filesystem, manipulate files, search for content, and chain commands together.
This journey does not cover: system administration, package management, networking, or shell scripting beyond one-liners.
How to use this page: Each task gives you a goal and links to relevant documentation. Read the docs, write your solution, and compare your output with the expected result. Complete the tasks in order - some depend on files created in earlier tasks.
Setup
Clone the onboarding repository if you haven't already:
git clone git@github.com:stratorys/onboarding.gitCreate your workspace and copy the practice files:
mkdir -p ~/linux-practicecp onboarding/docs/public/assets/linux/server.log ~/linux-practice/cp onboarding/docs/public/assets/linux/users.csv ~/linux-practice/cd ~/linux-practiceWriting scripts
Each task asks you to write a small script. A script is a text file that runs commands:
#!/bin/bash
your-command-hereSave it, make it executable with chmod +x script.sh, and run it with ./script.sh.
Task 1: Count lines in a file
Goal: Write a script count_lines.sh that prints the number of lines in server.log.
INFO
wc stands for "word count" but it counts more than words.
Docs:
Expected output:
> ./count_lines.sh
1847Task 2: Read the first and last entries
Goal: Write a script first_last.sh that prints the first line and the last line of server.log.
Docs:
Expected output:
> ./first_last.sh
2024-03-15 10:00:00 INFO Server started version=2.4.1
2024-03-15 10:30:06 INFO Server shutdown completed gracefullyTask 3: Find errors with line numbers
Goal: Write a script find_errors.sh that prints every line containing ERROR in server.log, prefixed with its line number.
Docs:
Expected output:
> ./find_errors.sh
87:2024-03-15 10:01:26 ERROR Failed to connect to database error="connection refused"
342:2024-03-15 10:05:41 ERROR Disk usage critical threshold=95%
896:2024-03-15 10:15:15 ERROR Request timeout endpoint=/api/export
1204:2024-03-15 10:22:03 ERROR Out of memory during batch job=etl-daily
1698:2024-03-15 10:28:57 ERROR TLS certificate expired service=payment-gatewayTask 4: Count warnings
Goal: Write a script count_warnings.sh that prints how many lines in server.log contain WARN.
INFO
The | operator sends the output of one command as input to another. This is called a pipe.
Docs:
Expected output:
> ./count_warnings.sh
42Task 5: List unique log levels
Goal: Write a script list_levels.sh that prints every unique log level in server.log, sorted alphabetically, one per line.
The log format is: DATE TIME LEVEL MESSAGE.
Docs:
Expected output:
> ./list_levels.sh
DEBUG
ERROR
INFO
WARNTask 6: Save errors to a file
Goal: Write a script extract_errors.sh that saves all ERROR lines from server.log into a new file called errors.log.
INFO
> writes output to a file and overwrites it. >> appends to a file.
Docs:
Expected output:
> ./extract_errors.sh
> wc -l errors.log
5 errors.logTask 7: List unique roles
Goal: Write a script list_roles.sh that prints every unique role in users.csv, sorted alphabetically, one per line.
WARNING
The first line of users.csv is a header. Your output should not include column names.
Docs:
Expected output:
> ./list_roles.sh
admin
analyst
developer
managerTask 8: Count users per role
Goal: Write a script count_roles.sh that prints how many users have each role, from most to least.
Docs:
Expected output:
> ./count_roles.sh
118 developer
45 analyst
25 manager
12 adminTask 9: Find files by extension
Goal: Write a script find_logs.sh that lists every .log file in ~/linux-practice and its subdirectories.
Docs:
Expected output:
> ./find_logs.sh
./server.log
./errors.logTask 10: Lock a file
Goal: Make errors.log read-only for everyone: owner, group, and others can read, but nobody can write or execute.
WARNING
chmod changes permissions. chown changes ownership. They are different operations.
Docs:
Expected output:
> ls -l errors.log
-r--r--r-- 1 <user> <group> ... errors.logCleanup
rm -rf ~/linux-practiceYou now know enough terminal commands for daily development work. When you need something specific, use man <command> or <command> --help.