Bash scripting challenges
You solve short scripting tasks taken from real admin problems on your own, check them against test data and get them ready for review.
Level 201 · 16 lessons · 15 practice labs
Lessons
Files
- Find files with identical contents and report them
- A script that rotates its own logs
- Compare two folders and fill in what's missing
- Short task: review a colleague's script and find three bugs
Accounts
- A script that creates accounts from CSV and is safe to re-run
- List accounts that haven't logged in for a long time
- Report who has sudo rights and through which group
- Short task: add a dry-run mode that shows what would change
Services and resources
- A watchdog that restarts a stopped service and keeps a record
- A disk script that raises an alert past a threshold
- A script that tests a list of service ports
- Short task: hook your scripts into cron safely
Text and reports
- An hourly error summary from a log
- Report the configuration differences between two servers
- A simple HTML report from command output
- Capstone: a one-command status tool for the night shift
Practice labs
- Write a script that finds identical files: Write a script that groups and reports files with identical contents in a directory tree by their hashes.
- Write a script that rotates its own log: Write a script that rotates its log by number once it exceeds a size and keeps at most five old copies.
- Compare two folders and fill in what is missing: Write a script that finds files missing or different in the target compared with the source and copies only those.
- Read a script and predict what it deletes: Read a short clean-up script without running it, write down the files it would delete and confirm your prediction in a test directory.
- Find three bugs in a colleague's script: Find and fix the quoting, wrong condition and delete-with-empty-variable bugs in a clean-up script.
- Add a dry-run mode to a script: Add a dry-run option to an account-removal script that lists what it would do without changing anything.
- Write a re-runnable script that creates accounts from CSV: Write a script that creates the users in a CSV, skips existing ones and changes nothing on a second run.
- List accounts that have not logged in for a long time: Write a script that reports human accounts with no login for over ninety days from the last-login records.
- Report who has sudo and through which group: Write a script that parses sudoers rules and group memberships to show which rule gives each user their rights.
- Write a watchdog that restarts a stopped service: Write a script that restarts the service if it has stopped and logs each intervention with a timestamp.
- Write a disk script that alerts past a threshold: Write a script that checks every partition, emits a warning for those over the threshold and never repeats one within an hour.
- Write a script that tests service ports: Write a script that tests host and port pairs from a file with a timeout, summarises the closed ones and sets its exit code accordingly.
- Produce an hourly error summary from a log: Write a script that extracts errors per hour from the application log and highlights the busiest hour.
- Build a simple HTML report from command output: Create a script that writes disk, memory and service states into a single HTML file with a table.
- Write a one-command status tool for the night shift: Write a tool that summarises services, disk, load and recent errors on one coloured screen and exits non-zero on problems.
About this course
You solve short scripting tasks taken from real admin problems on your own, check them against test data and get them ready for review.
What you will learn
- Files
- Accounts
- Services and resources
- Text and reports
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.