Bird
Raised Fist0
Cybersecurityknowledge~20 mins

Linux security fundamentals in Cybersecurity - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
Linux Security Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Linux File Permissions

What is the output of the command ls -l for a file with permissions -rwxr-x--x?

Specifically, what does the permission string rwxr-x--x mean for the file owner, group, and others?

AOwner can execute only; group can read and execute; others can read and write.
BOwner can read and write; group can write and execute; others can read only.
COwner can read, write, and execute; group can write only; others have no permissions.
DOwner can read, write, and execute; group can read and execute; others can only execute.
Attempts:
2 left
💡 Hint

Remember the order of permissions is read (r), write (w), and execute (x) for owner, group, and others.

📋 Factual
intermediate
2:00remaining
Linux User Privileges and sudo

Which of the following statements about the sudo command in Linux is correct?

A<code>sudo</code> allows a user to run commands as another user, typically root, after authentication.
B<code>sudo</code> permanently grants root access to a user without password prompts.
C<code>sudo</code> is used to change file ownership between users.
D<code>sudo</code> disables all user permissions temporarily.
Attempts:
2 left
💡 Hint

Think about how sudo helps users perform tasks requiring higher privileges.

🔍 Analysis
advanced
2:00remaining
Analyzing Linux Firewall Rules

Given the following iptables rule, what is its effect?

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
AAllows outgoing TCP connections on port 22.
BBlocks all incoming TCP connections on port 22.
CAllows incoming TCP connections on port 22 (SSH).
DLogs all incoming TCP connections on port 22 without allowing them.
Attempts:
2 left
💡 Hint

Consider the chain INPUT and the target ACCEPT.

❓ Comparison
advanced
2:00remaining
Comparing Linux Authentication Methods

Which of the following best describes the difference between password-based and key-based SSH authentication?

APassword-based requires typing a password; key-based uses cryptographic keys for automatic authentication.
BPassword-based uses keys stored on the server; key-based requires manual password entry each time.
CPassword-based is more secure than key-based authentication.
DKey-based authentication disables encryption during SSH sessions.
Attempts:
2 left
💡 Hint

Think about how SSH keys work compared to passwords.

❓ Reasoning
expert
2:00remaining
Evaluating Linux Security Best Practices

Which of the following actions would most effectively reduce the risk of unauthorized root access on a Linux server?

AAllow root login only with a strong password over SSH.
BDisable root login over SSH and use <code>sudo</code> for administrative tasks.
CUse the root account for all daily tasks to monitor activity closely.
DRemove all user accounts except root to simplify management.
Attempts:
2 left
💡 Hint

Consider the principle of least privilege and secure remote access.

Practice

(1/5)
1. Which of the following best describes the primary purpose of Linux file permissions?
easy
A. To backup files regularly
B. To speed up file access times
C. To control who can read, write, or execute files
D. To encrypt files automatically

Solution

  1. Step 1: Understand file permissions in Linux

    Linux file permissions determine which users can read, write, or execute a file or directory.
  2. Step 2: Identify the purpose of permissions

    Permissions protect files by controlling access, not by speeding access, encrypting, or backing up.
  3. Final Answer:

    To control who can read, write, or execute files -> Option C
  4. Quick Check:

    File permissions = control access [OK]
Hint: Permissions control access rights to files and folders [OK]
Common Mistakes:
  • Confusing permissions with encryption
  • Thinking permissions speed up file access
  • Assuming permissions handle backups
2. Which command correctly changes the owner of a file named report.txt to user alice?
easy
A. chmod alice report.txt
B. chown alice report.txt
C. chgrp alice report.txt
D. owner alice report.txt

Solution

  1. Step 1: Identify the command to change file owner

    The chown command changes the owner of a file in Linux.
  2. Step 2: Match the command syntax

    The correct syntax is chown username filename, so chown alice report.txt is correct.
  3. Final Answer:

    chown alice report.txt -> Option B
  4. Quick Check:

    Change owner = chown [OK]
Hint: Use chown to change file ownership [OK]
Common Mistakes:
  • Using chmod instead of chown
  • Confusing chgrp (changes group) with chown
  • Typing invalid commands like owner
3. What will be the output of the command ls -l /etc/passwd in a typical Linux system?
medium
A. Deletes the passwd file
B. Displays the contents of the passwd file
C. Changes the permissions of the passwd file
D. Shows detailed information including permissions, owner, and size of the passwd file

Solution

  1. Step 1: Understand the ls -l command

    The ls -l command lists files with detailed info like permissions, owner, size, and modification date.
  2. Step 2: Apply to /etc/passwd

    Running ls -l /etc/passwd shows detailed info about the passwd file, not its contents or changes.
  3. Final Answer:

    Shows detailed information including permissions, owner, and size of the passwd file -> Option D
  4. Quick Check:

    ls -l = detailed file info [OK]
Hint: ls -l lists file details, not contents [OK]
Common Mistakes:
  • Confusing ls -l with cat command
  • Thinking ls -l changes file permissions
  • Assuming ls -l deletes files
4. You try to change a file's permissions using chmod 777 file.txt but get a 'Permission denied' error. What is the most likely cause?
medium
A. You are not the file owner or lack sudo privileges
B. The file does not exist
C. chmod command is misspelled
D. The file is already set to 777

Solution

  1. Step 1: Understand permission requirements for chmod

    Only the file owner or a user with sudo rights can change file permissions.
  2. Step 2: Analyze the error cause

    A 'Permission denied' error means you lack rights to modify the file, not that the file is missing or command is wrong.
  3. Final Answer:

    You are not the file owner or lack sudo privileges -> Option A
  4. Quick Check:

    Permission denied = insufficient rights [OK]
Hint: Permission denied means you lack rights or sudo [OK]
Common Mistakes:
  • Assuming file doesn't exist
  • Thinking chmod command is incorrect
  • Believing file is already set to 777
5. A system administrator wants to restrict SSH access to only users in the group sshusers. Which configuration change in /etc/ssh/sshd_config achieves this?
hard
A. Add the line: AllowGroups sshusers and restart SSH service
B. Add the line: DenyUsers sshusers and restart SSH service
C. Change file permissions of /etc/ssh/sshd_config to 777
D. Disable SSH service completely

Solution

  1. Step 1: Identify SSH access control options

    The AllowGroups directive in sshd_config limits SSH login to specified groups.
  2. Step 2: Apply the correct configuration and restart SSH

    Adding AllowGroups sshusers and restarting SSH restricts access to that group only.
  3. Final Answer:

    Add the line: AllowGroups sshusers and restart SSH service -> Option A
  4. Quick Check:

    AllowGroups limits SSH access by group [OK]
Hint: Use AllowGroups in sshd_config to restrict SSH access [OK]
Common Mistakes:
  • Using DenyUsers instead of AllowGroups
  • Changing permissions to 777 (unsafe)
  • Disabling SSH instead of restricting access