📖 Scenario: You want to find the path your data takes to reach a website. This helps you understand how your internet connection travels through different servers.
🎯 Goal: Build a simple script that uses traceroute to trace the path to a website and shows the result.
📋 What You'll Learn
Use the traceroute command to trace the path to example.com
Store the target website in a variable called target
Use a variable called max_hops to limit the number of hops to 5
Run traceroute with the -m option using max_hops
Print the traceroute output
💡 Why This Matters
🌍 Real World
Network administrators and users use traceroute to diagnose network paths and delays.
💼 Career
Understanding traceroute helps in troubleshooting network issues and improving connectivity.
Progress0 / 4 steps
1
Set the target website
Create a variable called target and set it to the string example.com.
Linux CLI
Hint
Use target="example.com" to store the website.
2
Set the maximum hops
Create a variable called max_hops and set it to the number 5.
Linux CLI
Hint
Use max_hops=5 to limit the hops.
3
Run traceroute with max hops
Write a command that runs traceroute with the -m option set to max_hops and the target set to target. Use command substitution to store the output in a variable called result.
Linux CLI
Hint
Use result=$(traceroute -m $max_hops $target) to run traceroute and save output.
4
Print the traceroute result
Print the contents of the variable result to show the traceroute output.
Linux CLI
Hint
Use printf "%s\n" "$result" to print the output.
Practice
(1/5)
1. What is the main purpose of the traceroute command in Linux?
easy
A. To display current network connections
B. To list all files in a directory
C. To change the IP address of the system
D. To show the path data takes to reach a destination
Solution
Step 1: Understand traceroute function
The traceroute command traces the route packets take to reach a network host.
Step 2: Compare options
Options A, B, and D describe unrelated commands or functions.
Final Answer:
To show the path data takes to reach a destination -> Option D