Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Service and Port Management Basics
📖 Scenario: You are a network administrator managing a small office network. You need to keep track of which services run on which ports to ensure security and proper access.
🎯 Goal: Build a simple list of common services with their port numbers, then filter to find services running on ports below 1024, which are considered well-known ports.
📋 What You'll Learn
Create a dictionary called services with these exact entries: 'HTTP': 80, 'HTTPS': 443, 'FTP': 21, 'SSH': 22, 'SMTP': 25
Create a variable called well_known_port_limit and set it to 1024
Create a new dictionary called well_known_services that includes only the services from services running on ports less than well_known_port_limit
Add a final line that creates a list called service_names containing only the names of the services in well_known_services
💡 Why This Matters
🌍 Real World
Network administrators often need to know which services run on which ports to configure firewalls and monitor network traffic.
💼 Career
Understanding service and port management is essential for cybersecurity roles, network engineering, and system administration.
Progress0 / 4 steps
1
Create the services dictionary
Create a dictionary called services with these exact entries: 'HTTP': 80, 'HTTPS': 443, 'FTP': 21, 'SSH': 22, 'SMTP': 25
Cybersecurity
Hint
Use curly braces {} to create a dictionary with service names as keys and port numbers as values.
2
Set the well-known port limit
Create a variable called well_known_port_limit and set it to 1024
Cybersecurity
Hint
Just assign the number 1024 to the variable well_known_port_limit.
3
Filter well-known services
Create a new dictionary called well_known_services that includes only the services from services running on ports less than well_known_port_limit
Cybersecurity
Hint
Use dictionary comprehension to select services with ports less than well_known_port_limit.
4
List the names of well-known services
Add a final line that creates a list called service_names containing only the names of the services in well_known_services
Cybersecurity
Hint
Use the keys() method on the dictionary and convert it to a list.
Practice
(1/5)
1. What is the main purpose of managing services and ports on a computer system?
easy
A. To control which services are accessible and improve security
B. To increase the speed of the internet connection
C. To install new software automatically
D. To backup all files on the system
Solution
Step 1: Understand service and port roles
Services use ports to communicate over networks, so managing them controls access.
Step 2: Identify the security benefit
Closing unused ports prevents unauthorized access, improving system security.
Final Answer:
To control which services are accessible and improve security -> Option A
Quick Check:
Service and port management = Control access [OK]
Hint: Managing ports controls access to services for security [OK]
Common Mistakes:
Confusing port management with internet speed
Thinking it installs software
Assuming it backs up files
2. Which of the following is the correct way to specify a port number when configuring a service?
easy
A. Using letters instead of numbers
B. Using any number above 70000
C. Using negative numbers
D. Using a number between 0 and 65535
Solution
Step 1: Recall valid port number range
Ports are numbered from 0 to 65535 according to networking standards.
Step 2: Eliminate invalid options
Numbers above 65535, negative numbers, or letters are invalid for ports.
Final Answer:
Using a number between 0 and 65535 -> Option D
Quick Check:
Port numbers range 0-65535 [OK]
Hint: Ports must be 0-65535, no letters or negatives [OK]
Common Mistakes:
Choosing numbers above 65535
Using negative numbers
Using letters as ports
3. Consider a server running a web service on port 80 and an SSH service on port 22. If the firewall blocks port 22 but allows port 80, what will happen?
medium
A. Users can access the web service but cannot connect via SSH
B. Users can connect via SSH but cannot access the web service
C. Both web and SSH services will be accessible
D. Neither web nor SSH services will be accessible
Solution
Step 1: Identify allowed and blocked ports
Port 80 (web) is allowed; port 22 (SSH) is blocked by the firewall.
Step 2: Determine service accessibility
Web service on port 80 will be accessible; SSH on port 22 will be blocked.
Final Answer:
Users can access the web service but cannot connect via SSH -> Option A
Quick Check:
Firewall blocks port 22, allows 80 = Web yes, SSH no [OK]
Hint: Blocked port means service on it is inaccessible [OK]
Common Mistakes:
Assuming blocked port still allows access
Confusing port numbers with services
Thinking all services are blocked
4. A system administrator tries to start a service on port 21 but gets an error. The port is already in use by another service. What is the best way to fix this?
medium
A. Restart the computer without checking the port
B. Ignore the error and run both services on port 21
C. Change the new service to use a different free port
D. Uninstall the operating system
Solution
Step 1: Understand port conflict
Two services cannot use the same port simultaneously; this causes errors.
Step 2: Choose a solution to avoid conflict
Changing the new service to a free port resolves the conflict safely.
Final Answer:
Change the new service to use a different free port -> Option C
Quick Check:
Port conflict fixed by using different port [OK]
Hint: Use a free port to avoid conflicts [OK]
Common Mistakes:
Restarting without fixing port conflict
Trying to run two services on same port
Taking extreme actions like uninstalling OS
5. You want to secure a server by closing all unused ports but keep services on ports 22 (SSH), 80 (HTTP), and 443 (HTTPS) open. Which approach is best?
hard
A. Disable all services including SSH, HTTP, and HTTPS
B. Configure the firewall to block all ports except 22, 80, and 443
C. Open all ports to avoid blocking any service
D. Only block port 80 and 443, keep others open
Solution
Step 1: Identify required open ports
Services on ports 22, 80, and 443 must remain accessible for SSH and web traffic.
Step 2: Apply firewall rules to block unused ports
Blocking all other ports except these three limits exposure and secures the server.
Final Answer:
Configure the firewall to block all ports except 22, 80, and 443 -> Option B
Quick Check:
Block unused ports, keep needed open = Secure server [OK]
Hint: Block all except needed ports for best security [OK]