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
Logging and Audit Trails
📖 Scenario: You work as a security analyst. Your job is to keep track of user actions on a system. This helps detect problems and keeps a record of what happened.
🎯 Goal: Create a simple logging system that records user actions with timestamps. You will build a list of logs, add a filter for important actions, and then display the filtered logs.
📋 What You'll Learn
Create a list called user_actions with exact user action entries.
Add a variable called important_action to filter logs.
Use a list comprehension to create filtered_logs with only important actions.
Print the filtered_logs list.
💡 Why This Matters
🌍 Real World
Logging user actions helps detect security issues and keeps a record for audits.
💼 Career
Security analysts and DevOps engineers use logging to monitor system activity and investigate incidents.
Progress0 / 4 steps
1
Create the initial user actions list
Create a list called user_actions with these exact entries: 'login', 'view_page', 'edit_profile', 'logout', 'delete_account'.
Cybersecurity
Hint
Use square brackets to create a list and include the exact strings separated by commas.
2
Add a filter for important actions
Create a variable called important_action and set it to the string 'delete_account'.
Cybersecurity
Hint
Assign the string 'delete_account' to the variable important_action.
3
Filter logs for important actions
Use a list comprehension to create a list called filtered_logs that includes only entries from user_actions equal to important_action.
Cybersecurity
Hint
Use the syntax: [item for item in list if condition] to filter the list.
4
Display the filtered logs
Write a print statement to display the filtered_logs list.
Cybersecurity
Hint
Use print(filtered_logs) to show the filtered list.
Practice
(1/5)
1. What is the main purpose of logging in cybersecurity?
easy
A. To speed up the computer's processing power
B. To record important system and user actions for review
C. To delete old files automatically
D. To block unauthorized users from accessing the system
Solution
Step 1: Understand the role of logging
Logging is used to keep a record of system and user activities.
Step 2: Identify the correct purpose
Logging helps in reviewing actions for security and troubleshooting.
Final Answer:
To record important system and user actions for review -> Option B
Quick Check:
Logging = Record actions [OK]
Hint: Logging means recording actions, not blocking or deleting [OK]
Common Mistakes:
Confusing logging with access control
Thinking logging speeds up processing
Assuming logging deletes files
2. Which of the following is the correct syntax to configure a basic log file in Linux using rsyslog?
easy
A. *.info /var/log/messages*
B. *.info /var/log/messages;
C. *.info > /var/log/messages
D. *.info /var/log/messages
Solution
Step 1: Review rsyslog syntax basics
In rsyslog, the format is: selector action, e.g., '*.info /var/log/messages'.
Step 2: Identify the correct syntax
*.info /var/log/messages matches the correct syntax without extra characters.
Final Answer:
*.info /var/log/messages -> Option D
Quick Check:
rsyslog syntax = selector + space + file path [OK]
Hint: No semicolon or special chars after file path in rsyslog config [OK]
Hint: Look for LOGIN FAILURE to spot failed login attempts [OK]
Common Mistakes:
Mixing user1 and user2 events
Confusing LOGIN SUCCESS with FAILURE
Ignoring timestamps
4. You configured auditd to log file access but notice no logs are generated. Which is the most likely cause?
medium
A. auditd service is not running
B. The log file is too large
C. The system clock is incorrect
D. The user has admin rights
Solution
Step 1: Check auditd service status
If auditd is not running, no audit logs will be created.
Step 2: Rule out other options
Log file size or system clock issues do not stop logging; admin rights do not prevent logs.
Final Answer:
auditd service is not running -> Option A
Quick Check:
auditd must run to log events [OK]
Hint: Ensure auditd service is active to generate logs [OK]
Common Mistakes:
Assuming large log files stop logging
Blaming system clock for missing logs
Thinking admin rights block logging
5. You want to create an audit trail that records user login and logout times, but only for users in the 'admin' group. Which approach best achieves this?
hard
A. Manually check login times daily for admin users
B. Enable system-wide logging for all users without filters
C. Configure audit rules to watch /var/log/auth.log and filter by admin group users
D. Disable logging for non-admin users
Solution
Step 1: Understand audit trail requirements
We need logs for login/logout only for admin group users.
Step 2: Choose filtering method
Configuring audit rules to watch auth logs and filter by group targets only admin users.
Step 3: Evaluate other options
System-wide logging is too broad; manual checks are inefficient; disabling logging for others may miss events.
Final Answer:
Configure audit rules to watch /var/log/auth.log and filter by admin group users -> Option C
Quick Check:
Audit rules + filtering = targeted logs [OK]
Hint: Use audit rules with filters to log specific user groups [OK]