💻

WEEK 9: BASH SCRIPTING MISSION

QHO443 Network Applications | Practical Skills Assessment

⏱️ Time Limit: 90 Minutes | 🎯 Complete All 5 Missions

90:00
Time Remaining

🎯 MISSION BRIEFING

Scenario: You are a junior system administrator at TechCorp Solutions. Your senior colleague is on leave, and you've been assigned urgent tasks that require Bash scripting skills.

📚 Structure: This assessment has two parts:

  • Part 1: Practice Tasks - Warm-up exercises (Easy, Medium, Hard) to build your confidence
  • Part 2: Main Missions - 5 real-world scenarios that combine all concepts

⚠️ Important: Test your scripts carefully. In the real world, one mistake in a script can affect entire systems!

📚 PART 1: PRACTICE TASKS

Before the main missions, let's warm up!

Complete these practice exercises to familiarize yourself with Bash concepts. They're organized by difficulty level. You can attempt them in any order, but we recommend starting with Easy tasks.

💡 Tip: These practice tasks will help you succeed in the main missions!

E1 Simple Echo Practice
EASY

Let's start with the absolute basics. Create a script that displays text on the screen.

🎯 OBJECTIVE: Write a script that displays "Hello from TechCorp!" on the screen.

REQUIREMENTS:

  • Include the shebang line
  • Use echo to display the message
$ ./hello.sh Hello from TechCorp!
💡 HINT

Remember: Every Bash script needs #!/bin/bash on the first line.

Use echo "your message" to display text.

Solution:

#!/bin/bash
echo "Hello from TechCorp!"
E2 Variable Storage
EASY

Practice storing data in a variable and displaying it.

🎯 OBJECTIVE: Store your name in a variable called "name" and display "My name is [your name]".

REQUIREMENTS:

  • Create a variable called "name"
  • Store any name in it (e.g., "Shaheer")
  • Display it using $name in an echo statement
$ ./myname.sh My name is Shaheer
💡 HINT

Create a variable: variablename="value" (NO spaces around =)

Use a variable: $variablename

Solution:

#!/bin/bash
name="Shaheer"
echo "My name is $name"
E3 Multiple Variables
EASY

Work with multiple variables to create a complete sentence.

🎯 OBJECTIVE: Store your name and favorite color in variables, then display them together.

REQUIREMENTS:

  • Create variable "name" with a name
  • Create variable "color" with a color
  • Display: "[name]'s favorite color is [color]"
$ ./favorites.sh Shaheer's favorite color is blue
💡 HINT

You can use multiple variables in one echo statement.

Solution:

#!/bin/bash
name="Shaheer"
color="blue"
echo "$name's favorite color is $color"
M1 Basic User Input
MEDIUM

Now let's make it interactive! Get input from the user.

🎯 OBJECTIVE: Ask for the user's favorite programming language and display a response.

REQUIREMENTS:

  • Ask: "What is your favorite programming language?"
  • Read the input into a variable called "language"
  • Display: "[language] is a great choice!"
$ ./fav_lang.sh What is your favorite programming language? Python Python is a great choice!
💡 HINT

Use read variablename to get input from the user.

The read command waits for the user to type something and press Enter.

Solution:

#!/bin/bash
echo "What is your favorite programming language?"
read language
echo "$language is a great choice!"
M2 Command Output to Variable
MEDIUM

Learn to capture command output and store it in a variable.

🎯 OBJECTIVE: Store the current date in a variable and display it with a message.

REQUIREMENTS:

  • Use command substitution to store date output
  • Store in a variable called "current_date"
  • Display: "Today's date is: [date]"
$ ./show_date.sh Today's date is: Thu Dec 19 2025
💡 HINT

Command substitution: variable=$(command)

The date command shows the current date and time.

Solution:

#!/bin/bash
current_date=$(date)
echo "Today's date is: $current_date"
M3 File Output Redirection
MEDIUM

Practice writing output to a file instead of the screen.

🎯 OBJECTIVE: Create a file called "info.txt" with three lines of information.

REQUIREMENTS:

  • First line: "System Information" (use > to create file)
  • Second line: Current date (use >> to append)
  • Third line: Current user (use >> to append)
  • Display "File created successfully" on screen
# The info.txt file should contain: System Information [Current date] [Current username]
💡 HINT

> creates or overwrites a file

>> appends to an existing file

Solution:

#!/bin/bash
echo "System Information" > info.txt
date >> info.txt
whoami >> info.txt
echo "File created successfully"
H1 Number Comparison
HARD

Use conditional statements to compare numbers.

🎯 OBJECTIVE: Ask for a number and check if it's greater than 50.

REQUIREMENTS:

  • Ask: "Enter a number:"
  • Read the number into a variable
  • If number > 50: display "Large number!"
  • If number ≤ 50: display "Small number!"
  • Use proper if-then-else-fi structure
$ ./number_check.sh Enter a number: 75 Large number! $ ./number_check.sh Enter a number: 30 Small number!
💡 HINT

IF structure: if [ condition ]; then ... else ... fi

Use -gt for "greater than" comparison

Solution:

#!/bin/bash
echo "Enter a number:"
read num
if [ $num -gt 50 ]
then
  echo "Large number!"
else
  echo "Small number!"
fi
H2 Password Validator
HARD

Create a simple password check system using string comparison.

🎯 OBJECTIVE: Ask for a password and check if it matches "TechCorp2025".

REQUIREMENTS:

  • Store correct password "TechCorp2025" in a variable
  • Ask: "Enter password:"
  • Read user input
  • If correct: "Access Granted"
  • If wrong: "Access Denied"
  • Use string comparison with = (single equals in if statement)
$ ./password.sh Enter password: TechCorp2025 Access Granted $ ./password.sh Enter password: wrong Access Denied
💡 HINT

For string comparison use: if [ "$var1" = "$var2" ]

Note: Use single = for string comparison in if statements

Solution:

#!/bin/bash
correct_pass="TechCorp2025"
echo "Enter password:"
read user_pass
if [ "$user_pass" = "$correct_pass" ]
then
  echo "Access Granted"
else
  echo "Access Denied"
fi
H3 File Existence Checker
HARD

Use file test operators to check if a file exists before processing.

🎯 OBJECTIVE: Check if a file called "config.txt" exists and display appropriate message.

REQUIREMENTS:

  • Check if file "config.txt" exists using -f test
  • If exists: "Configuration file found. Loading settings..."
  • If not exists: "Error: config.txt not found. Please create it first."
  • Use if-then-else-fi structure
$ ./config_check.sh # When file exists: Configuration file found. Loading settings... # When file doesn't exist: Error: config.txt not found. Please create it first.
💡 HINT

File test: if [ -f filename ] checks if file exists

The -f flag specifically checks for regular files

Solution:

#!/bin/bash
if [ -f config.txt ]
then
  echo "Configuration file found. Loading settings..."
else
  echo "Error: config.txt not found. Please create it first."
fi

🚀 PART 2: MAIN MISSIONS

Ready for the real challenge?

Now that you've warmed up with practice tasks, it's time for the main missions. These combine multiple concepts and simulate real-world scenarios you'll face as a system administrator.

Important: Complete missions in order - each one unlocks the next!

MISSION PROGRESS 0/5 Completed
0%
1 Welcome Message Script
READY

Your first task is simple but important. Create a script that welcomes new employees to TechCorp.

🎯 YOUR MISSION: Write a Bash script that asks for a user's name and displays a personalized welcome message.

REQUIREMENTS:

  • Must start with the correct shebang line
  • Ask the user "What is your name?"
  • Read the user's input and store it
  • Display: "Welcome to TechCorp, [name]! Let's automate the world together."
$ ./welcome.sh What is your name? Shaheer Welcome to TechCorp, Shaheer! Let's automate the world together.
💡 HINT SYSTEM - Click to Reveal
🟢 Hint 1: Getting Started
Every Bash script starts with #!/bin/bash on the first line. This tells Linux to use Bash to run your script.
🟡 Hint 2: Displaying Messages
Use echo "Your message here" to display text to the user.
🟠 Hint 3: Reading Input
Use read variablename to get input from the user and store it in a variable.
🔴 Hint 4: Almost There!
To use a variable's value, put a $ before it: $variablename. Your script structure should be:

#!/bin/bash
echo "What is your name?"
read name
echo "Welcome to TechCorp, $name! Let's automate the world together."
2 System Information Reporter
🔒 LOCKED

Create a script that generates a quick system information report - something your manager checks every morning.

🎯 YOUR MISSION: Write a script that collects and displays system information using variables and commands.

REQUIREMENTS:

  • Store today's date in a variable called "today"
  • Store the current logged-in user in a variable called "user"
  • Display "=== System Report ===" as a header
  • Display "Date: [today's date]"
  • Display "User: [username]"
  • Display "System: TechCorp Linux Server"
$ ./system_report.sh === System Report === Date: Thu Dec 19 2025 User: shaheer System: TechCorp Linux Server
💡 HINT SYSTEM - Click to Reveal
🟢 Hint 1: Command Substitution
To store a command's output in a variable, use: variablename=$(command)
Example: today=$(date)
🟡 Hint 2: Getting Username
The whoami command shows the current logged-in user. Store it like: user=$(whoami)
🟠 Hint 3: Script Structure
Your script needs:
1. Shebang line
2. Variable for date
3. Variable for user
4. Four echo statements to display the report
🔴 Hint 4: Complete Solution
#!/bin/bash
today=$(date)
user=$(whoami)
echo "=== System Report ==="
echo "Date: $today"
echo "User: $user"
echo "System: TechCorp Linux Server"
3 Server Log Creator
🔒 LOCKED

You need to create log files for server monitoring. These logs will track system activities throughout the day.

🎯 YOUR MISSION: Write a script that creates a log file and records important system information using output redirection.

REQUIREMENTS:

  • Create/overwrite a file called "server.log" with "=== Server Log ===" as the first line
  • Append the current date and time to the log
  • Append the text "Server Status: Online"
  • Append the current logged-in user
  • Display "Log file created successfully" on the screen
# After running your script, the server.log file should contain: === Server Log === [Current date and time] Server Status: Online [Username]
💡 HINT SYSTEM - Click to Reveal
🟢 Hint 1: Output Redirection Basics
> creates or overwrites a file
>> appends to a file
Example: echo "text" > file.txt
🟡 Hint 2: First Line Strategy
Use > for the first line to create/overwrite the file:
echo "=== Server Log ===" > server.log
🟠 Hint 3: Adding More Lines
Use >> for all subsequent lines:
date >> server.log
echo "text" >> server.log
whoami >> server.log
🔴 Hint 4: Complete Solution
#!/bin/bash
echo "=== Server Log ===" > server.log
date >> server.log
echo "Server Status: Online" >> server.log
whoami >> server.log
echo "Log file created successfully"
4 Age Verification System
🔒 LOCKED

TechCorp is creating an employee portal. You need to build an age verification script to ensure users meet the minimum age requirement of 18.

🎯 YOUR MISSION: Write a script that uses IF-ELSE conditional statements to check if a user meets the age requirement.

REQUIREMENTS:

  • Ask "Enter your age:"
  • Read the user's age input
  • If age is 18 or greater: display "Access Granted: Welcome to TechCorp Portal"
  • If age is less than 18: display "Access Denied: You must be 18 or older"
  • Use proper if-then-else-fi structure
# Test Case 1: $ ./age_check.sh Enter your age: 25 Access Granted: Welcome to TechCorp Portal # Test Case 2: $ ./age_check.sh Enter your age: 16 Access Denied: You must be 18 or older
💡 HINT SYSTEM - Click to Reveal
🟢 Hint 1: IF Statement Structure
Basic structure:
if [ condition ]
then
  commands
else
  commands
fi
🟡 Hint 2: Comparison Operators
For numbers:
-ge means "greater than or equal to"
-lt means "less than"
Example: [ $age -ge 18 ]
🟠 Hint 3: Building the Logic
1. Read age into a variable
2. Check if $age -ge 18
3. If true: print "Access Granted" message
4. If false: print "Access Denied" message
🔴 Hint 4: Complete Solution
#!/bin/bash
echo "Enter your age:"
read age
if [ $age -ge 18 ]
then
  echo "Access Granted: Welcome to TechCorp Portal"
else
  echo "Access Denied: You must be 18 or older"
fi
5 Backup File Checker
🔒 LOCKED

FINAL MISSION: Your most important task. TechCorp runs daily backups, but sometimes the backup file goes missing. Create a script to check if the backup exists before proceeding.

🎯 YOUR MISSION: Write a script that checks if a backup file exists and takes appropriate action.

REQUIREMENTS:

  • Ask "Enter backup filename to check:"
  • Read the filename from the user
  • Check if the file exists using the -f test
  • If file exists: display "✅ SUCCESS: Backup file found. System is safe."
  • If file doesn't exist: display "⚠️ WARNING: Backup file not found. Please create backup immediately!"
# When file exists: $ ./backup_check.sh Enter backup filename to check: backup.tar.gz ✅ SUCCESS: Backup file found. System is safe. # When file doesn't exist: $ ./backup_check.sh Enter backup filename to check: missing.txt ⚠️ WARNING: Backup file not found. Please create backup immediately!
💡 HINT SYSTEM - Click to Reveal
🟢 Hint 1: File Test Operator
-f filename checks if a file exists
Use it in an if statement: if [ -f $filename ]
🟡 Hint 2: Getting the Filename
Ask for the filename and store it:
echo "Enter backup filename to check:"
read filename
🟠 Hint 3: IF-ELSE Structure
Structure your condition:
if [ -f $filename ]
then
  # File exists message
else
  # File not found message
fi
🔴 Hint 4: Complete Solution
#!/bin/bash
echo "Enter backup filename to check:"
read filename
if [ -f $filename ]
then
  echo "✅ SUCCESS: Backup file found. System is safe."
else
  echo "⚠️ WARNING: Backup file not found. Please create backup immediately!"
fi