LFCS Linux Foundation Certified System Administrator (LFCS) Free Practice Exam Questions (2026 Updated)
Prepare effectively for your Linux Foundation LFCS Linux Foundation Certified System Administrator (LFCS) certification with our extensive collection of free, high-quality practice questions. Each question is designed to mirror the actual exam format and objectives, complete with comprehensive answers and detailed explanations. Our materials are regularly updated for 2026, ensuring you have the most current resources to build confidence and succeed on your first attempt.
Task
The task is presented as a network traffic redirection diagram in the video.
Original diagram extracted from the recording. Its lower portion is outside the visible exam window.
The visible diagram identifies incoming TCP port 80, traffic from 172.16.123.0/28, and destination port 8080. The candidate's terminal commands also reference destination port 9080.
Transcription limitation: The recording does not reveal the complete diagram or any instructions below it. Therefore, the exact full task statement cannot be reproduced without guessing. The solution below addresses the two redirection paths indicated by the visible diagram and candidate commands, with the rule-ordering error corrected.
The Answer Is:
See the complete solution in Explanation.
Explanation:
Objective: Configure Linux iptables to perform destination-port redirection using the NAT table.
The recording suggests this intended behavior:
Incoming source
Original destination port
Redirected local port
172.16.123.0/28
TCP 80
TCP 9080
All other IPv4 sources
TCP 80
TCP 8080
The second destination, 9080, comes from the candidate's terminal commands, not the fully visible task diagram. It must therefore be treated as an inferred requirement.
A crucial technical issue is rule priority: the more specific subnet rule must be evaluated before the general port-80 rule. Otherwise, the general rule captures the subnet traffic first.
Step 1: Connect to the correct Linux server.
The recording specifies host lfcs00074.
Execute:
ssh candidate@lfcs00074
This connects to the designated host on which the firewall and NAT configuration must be performed.
Step 2: Verify that iptables is available.
Execute:
sudo iptables --version
This displays the iptables version and may indicate whether the system uses the nf_tables or legacy backend.
For example:
iptables v1.8.x (nf_tables)
The actual version depends on the installed environment.
Step 3: Inspect the existing NAT configuration.
Execute:
sudo iptables -t nat -L -n -v
-t nat selects the Network Address Translation table.
-L lists rules.
-n displays numerical IP addresses and port numbers.
-v provides verbose output, including packet and byte counters.
The NAT table contains chains including PREROUTING, OUTPUT, and POSTROUTING.
For incoming connections being redirected to local services, the relevant chain is normally PREROUTING.
Step 4: Display the PREROUTING rules with line numbers.
Execute:
sudo iptables -t nat -L PREROUTING -n -v --line-numbers
This displays the order in which incoming packets encounter the NAT rules.
Also execute:
sudo iptables -t nat -S PREROUTING
The second command displays the rules in a format similar to the commands used to configure them.
Check whether there are already rules that redirect TCP port 80.
Avoid creating duplicate or contradictory rules.
Step 5: Understand the required redirection mechanism.
The Linux REDIRECT target changes the destination of a matching packet so that it is delivered to the local machine, optionally changing its destination port.
For example:
sudo iptables -t nat -A PREROUTING \
-p tcp --dport 80 \
-j REDIRECT --to-ports 8080
This redirects incoming TCP connections originally targeting port 80 to local port 8080.
The official iptables-extensions(8) manual confirms that REDIRECT is supported in the NAT table's PREROUTING and OUTPUT chains.
Linux manual page
Step 6: Configure the source-specific rule first.
For the inferred special handling of subnet 172.16.123.0/28, execute:
sudo iptables -t nat -I PREROUTING 1 \
-s 172.16.123.0/28 \
-p tcp --dport 80 \
-j REDIRECT --to-ports 9080
Option
Purpose
-t nat
Selects the NAT table
-I PREROUTING 1
Inserts the rule at position 1
-s 172.16.123.0/28
Matches packets originating from that subnet
-p tcp
Matches TCP traffic
--dport 80
Matches original destination port 80
-j REDIRECT
Redirects the packet to the local machine
--to-ports 9080
Changes the destination port to 9080
The -I PREROUTING 1 option is important because it places the specific rule at the beginning of the chain, ahead of broader rules appended later.
Do not run this command if an equivalent correct rule already exists; inspect and reconcile the existing configuration first.
Step 7: Configure the general port redirection.
Provided an equivalent general rule is not already present, execute:
sudo iptables -t nat -A PREROUTING \
-p tcp --dport 80 \
-j REDIRECT --to-ports 8080
This handles incoming TCP port-80 connections that did not match an earlier terminating rule.
Because the source-specific rule has higher priority, the expected behavior is:
Connections from 172.16.123.0/28 are redirected to 9080.
Other incoming TCP port-80 connections are redirected to 8080.
The general rule does not require a source restriction because it is the fallback rule.
Step 8: Understand why the rule order matters.
The candidate initially enters the broad redirect to 8080 and later adds the subnet-specific redirect to 9080.
That sequence is problematic.
Consider these two rules in this order:
sudo iptables -t nat -A PREROUTING \
-p tcp --dport 80 \
-j REDIRECT --to-ports 8080
sudo iptables -t nat -A PREROUTING \
-s 172.16.123.0/28 \
-p tcp --dport 80 \
-j REDIRECT --to-ports 9080
The first rule matches all incoming TCP port-80 connections, including those from the special subnet.
Since a REDIRECT target terminates further rule evaluation for that NAT decision, the later subnet rule will not receive those matching connections.
Correct order:
Rule 1: Subnet 172.16.123.0/28 → Port 9080
Rule 2: Other TCP port-80 connections → Port 8080
The Linux iptables manual documents sequential rule evaluation and matching behavior.
Linux manual page
Step 9: Verify the configured NAT rules.
Execute:
sudo iptables -t nat -L PREROUTING \
-n -v --line-numbers
The relevant rule sequence should resemble:
1 REDIRECT tcp -- 172.16.123.0/28 0.0.0.0/0 tcp dpt:80 redir ports 9080
2 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8080
The output format may vary.
If existing unrelated rules are present, preserve them. The two example lines do not imply that the real NAT table should contain only two rules.
Step 10: Correct any incorrectly ordered rules.
If the general port-80 rule is already first, the specific rule can be inserted ahead of it using:
sudo iptables -t nat -I PREROUTING 1 \
-s 172.16.123.0/28 \
-p tcp --dport 80 \
-j REDIRECT --to-ports 9080
Before doing so, make sure an identical subnet rule is not already present.
If the previous candidate commands created duplicate entries, list the chain:
sudo iptables -t nat -L PREROUTING -n --line-numbers
Then carefully remove only confirmed duplicate or erroneous entries by their current rule number:
sudo iptables -t nat -D PREROUTING RULE_NUMBER
Replace RULE_NUMBER with the actual displayed number.
Rule numbers can change after each deletion, so inspect the chain again before deleting another entry.
Do not flush the entire NAT table.
Step 11: Verify that the destination services are available.
Execute:
sudo ss -ltnp
To examine the relevant ports:
sudo ss -ltnp | grep -E ':(8080|9080)\b'
This checks whether processes are listening on TCP ports 8080 and 9080.
The iptables rules may be syntactically correct even if no service is currently listening. However, actual connection delivery requires an appropriate local service and any necessary firewall permission.
A NAT redirection rule does not automatically start the destination application.
Step 12: Check whether filtering rules permit redirected connections.
Execute:
sudo iptables -L INPUT -n -v
Check whether the existing INPUT chain allows connections to the effective destination ports.
The REDIRECT target changes the packet's destination, but a restrictive filter policy can still block delivery.
Do not add broad ACCEPT rules unless the actual task requires them and the existing firewall policy warrants the change.
Step 13: Test traffic from the specified subnet.
From a machine whose source address belongs to:
172.16.123.0/28
Initiate a fresh TCP connection to port 80 on the appropriate IP address of lfcs00074.
For an HTTP-based service, a test could use:
curl -v http://SERVER_IP:80/
Replace SERVER_IP with the real server address.
If the inferred subnet-specific rule is correct, the connection should reach the local service listening on port 9080.
A destination service's response or a packet trace can establish which port received the connection.
Step 14: Test traffic from outside the specified subnet.
From a client outside 172.16.123.0/28, initiate another new connection to the same server's TCP port 80.
The general rule should redirect that traffic to port 8080, provided no earlier rule intercepts it.
Do not rely only on a test from:
curl http://localhost:80
Locally generated traffic traverses the NAT OUTPUT chain rather than the incoming PREROUTING chain. It is therefore not a valid test of these PREROUTING rules.
Step 15: Inspect rule counters.
Execute:
sudo iptables -t nat -L PREROUTING \
-n -v --line-numbers
Review the packet and byte counters.
New matching connections should increment the applicable rule's counters.
Because NAT decisions are generally made for the initial packets of tracked connections, established connections may not increment counters in the way ordinary filter-chain traffic does.
Use fresh connections for testing.
Step 16: Preserve the rules if persistence is required.
The video shows the candidate using:
sudo service netfilter-persistent save
For a system with the appropriate netfilter-persistent plugins installed, the documented command is:
sudo netfilter-persistent save
This saves the active firewall rules through the installed persistence plugins.
Ubuntu's netfilter-persistent(8) manual documents the save operation.
Ubuntu Manpages
Before relying on it, check that the service and IPv4 plugin are installed:
command -v netfilter-persistent
ls -l /usr/share/netfilter-persistent/plugins.d/
If persistence is required, verify the saved IPv4 rules:
sudo grep -A 20 '^\*nat' /etc/iptables/rules.v4
The saved configuration should contain the correctly ordered rules.
Persistence is not explicitly visible in the task statement, so treat it as an additional measure suggested by the recorded candidate actions, not a proven requirement.
Step 17: Perform final verification.
Execute:
sudo iptables -t nat -S PREROUTING
sudo iptables -t nat -L PREROUTING -n -v --line-numbers
sudo ss -ltnp | grep -E ':(8080|9080)\b'
For the inferred two-rule requirement, the expected configuration is:
Verification
Expected behavior
Source subnet
172.16.123.0/28
Original destination
TCP port 80
Special-subnet destination
TCP port 9080
General destination
TCP port 8080
Specific rule priority
Before general rule
NAT table
nat
NAT chain
PREROUTING
Existing unrelated rules
Preserved
Final Solution
For the two redirection paths inferred from the recording, and assuming equivalent rules do not already exist, the essential command sequence is:
# Connect to the required server
ssh candidate@lfcs00074
# Inspect existing NAT rules
sudo iptables -t nat -S PREROUTING
# Specific subnet: TCP 80 → 9080
# This rule must have higher priority.
sudo iptables -t nat -I PREROUTING 1 \
-s 172.16.123.0/28 \
-p tcp --dport 80 \
-j REDIRECT --to-ports 9080
# General traffic: TCP 80 → 8080
sudo iptables -t nat -A PREROUTING \
-p tcp --dport 80 \
-j REDIRECT --to-ports 8080
# Verify rule ordering and counters
sudo iptables -t nat -L PREROUTING \
-n -v --line-numbers
# If persistence is required and configured
sudo netfilter-persistent save
Technical Verification and References
Linux iptables(8)
— Documents rule insertion, ordering, matching and chain operations.
Linux iptables-extensions(8)
— Defines the REDIRECT target and --to-ports option.
Ubuntu netfilter-persistent(8)
— Documents saving and restoring firewall rules.
Video verification finding: The candidate's commands reveal an attempted redirect from port 80 to 8080 and a separate source-specific redirect from port 80 to 9080. The specific rule was appended after the general rule, which would prevent the special-subnet redirect from taking effect as intended. The corrected sequence places the specific rule first.
Verification limitation: The full task diagram is never visible, so the inferred two-rule interpretation cannot be certified as the exact complete exam requirement. The command syntax and priority correction are validated against Linux documentation, but the final intended behavior requires the missing diagram portion and runtime connection tests.
next please
Worked for 3m 12s
Task
The system service apache2 is failing to start.
First, troubleshoot the failure and fix it.
Finally, start the systemd service and ensure it is running.
The Answer Is:
See the complete solution in Explanation.
Explanation:
Step 1: Connect to the correct Linux server.
The video specifies that this task must be performed on host lfcs00101a.
From the candidate terminal, execute:
ssh lfcs00101a
This establishes an SSH session with the server where the Apache service is failing.
All subsequent troubleshooting, configuration changes, and service operations must be performed on this host.
Step 2: Check the current status of the Apache service.
Execute:
sudo systemctl status apache2
This is the primary systemd command for checking the status of Apache.
It displays information such as:
Whether the apache2 service is loaded.
Whether the service is running, inactive or failed.
The process ID and execution status.
Recent service log messages.
Errors reported during startup.
An illustrative failure might appear as follows:
× apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Active: failed (Result: exit-code)
Process: 1234 ExecStart=/usr/sbin/apachectl start
Main PID: 1234 (code=exited, status=1/FAILURE)
This is an example, not an output confirmed from the supplied video.
The Active: failed status means the service was unable to complete startup successfully.
Use the actual error messages to determine the cause.
Step 3: Examine the Apache service logs.
Execute:
sudo journalctl -u apache2 -b --no-pager
journalctl displays logs collected by systemd.
-u apache2 filters messages associated with the Apache service.
-b restricts results to the current boot.
--no-pager prints output directly without opening an interactive pager.
To display only the latest 50 messages:
sudo journalctl -u apache2 -n 50 --no-pager
These logs help identify why Apache failed.
Possible causes include:
Incorrect permissions on the Apache executable.
Invalid configuration directives.
Missing configuration files.
Another process using the required network port.
Inaccessible log directories.
Missing modules or other dependencies.
The official systemd documentation supports using journalctl -u to investigate the logs associated with a particular service.
Freedesktop
Step 4: Check the Apache executable.
On Ubuntu, the Apache server executable is normally located at:
/usr/sbin/apache2
Verify its existence:
ls -l /usr/sbin/apache2
For a more detailed permissions check:
stat -c '%A %a %U:%G %n' /usr/sbin/apache2
A correctly installed executable would typically have permissions similar to:
-rwxr-xr-x 755 root:root /usr/sbin/apache2
The x characters represent execute permission.
For example, if the permissions were incorrectly changed to:
-rw-r--r--
the executable would lack execution permission.
This can prevent Apache from starting successfully.
Step 5: Inspect the complete path permissions.
Execute:
namei -l /usr/sbin/apache2
This examines the permission bits and ownership of each directory component leading to the executable.
It helps distinguish between:
A non-executable Apache binary.
A directory that lacks search permission.
Incorrect ownership or permissions elsewhere in the path.
Also verify which package owns the executable:
dpkg -S /usr/sbin/apache2
On Ubuntu, it normally belongs to the apache2-bin package.
If required, check package-file integrity:
sudo dpkg -V apache2-bin
Package verification can help identify unexpectedly modified permissions or file contents.
Step 6: Correct the executable permission if it is the source of the failure.
In the supplied video, the candidate executes:
sudo chmod +x /usr/sbin/apache2
This is an important observation.
The command adds execute permission to the Apache executable according to the applicable chmod rules.
However, the candidate does not visibly demonstrate the earlier diagnostic output proving that missing execute permission caused the failure.
If the executable genuinely lacks its required execute permission, restore its expected mode:
sudo chmod 755 /usr/sbin/apache2
chmod changes file permissions.
755 grants read, write and execute permissions to the owner.
755 grants read and execute permissions to the group.
755 grants read and execute permissions to other users.
This is appropriate for a standard root-owned Apache executable when its mode has been incorrectly changed.
Do not execute this as a universal fix if the actual failure is a configuration error or port conflict.
Step 7: Verify the corrected permissions.
Execute:
ls -l /usr/sbin/apache2
Expected permissions, assuming the standard installation:
-rwxr-xr-x
For numerical verification:
stat -c '%a %n' /usr/sbin/apache2
Expected:
755 /usr/sbin/apache2
If the file's ownership is also incorrect, compare it with the package's expected ownership before making additional changes.
Step 8: Check the Apache configuration syntax.
Execute:
sudo apache2ctl configtest
This checks the Apache configuration for syntax errors.
For a valid configuration, the expected output is:
Syntax OK
The Apache control utility supports the configtest operation specifically for validating configuration syntax.
Apache HTTP Server Version 2.4
If it reports an error, inspect the identified file and line.
For example, an illustrative error might be:
Syntax error on line 42 of /etc/apache2/apache2.conf
Invalid command 'InvalidDirective'
In that case, correct the configuration directive instead of modifying executable permissions.
A successful syntax check does not guarantee that Apache can start, but it eliminates many configuration-related problems.
Step 9: Check whether Apache's required network ports are available.
Apache commonly listens on TCP port 80 for HTTP and port 443 for HTTPS.
Execute:
sudo ss -ltnp
To examine those ports specifically:
sudo ss -ltnp | grep -E ':(80|443)\b'
If another service already occupies a port configured for Apache, startup may fail with an address-binding error.
The official Apache documentation identifies port-binding conflicts as a common startup failure.
Apache HTTP Server Version 2.4
Do not stop another service unless the diagnostic evidence establishes that it is the source of the problem and the change is appropriate.
Step 10: Check Apache's own error log if necessary.
Execute:
sudo tail -n 50 /var/log/apache2/error.log
This displays recent entries from the standard Ubuntu Apache error log.
The file may contain additional details not included in the systemd journal.
Look for permission errors, configuration failures, missing resources or binding errors.
If the executable-permission repair was the only required correction, there may be no additional configuration changes to make.
Step 11: Start the Apache service.
After correcting the identified problem, execute:
sudo systemctl start apache2
sudo provides administrative privileges.
systemctl manages systemd services.
start requests that the specified service begin running.
apache2 identifies the Apache service unit.
This command directly satisfies the task's instruction to start the systemd service.
In the video, the candidate uses:
sudo systemctl restart apache2
The restart operation stops and starts an active service or starts it when appropriate.
Either operation can result in Apache running, but systemctl start apache2 is the more direct choice when the service is currently stopped or failed.
Step 12: Verify that Apache is running.
Execute:
sudo systemctl status apache2
Expected successful status:
● apache2.service - The Apache HTTP Server
Loaded: loaded
Active: active (running)
The critical field is:
Active: active (running)
This indicates that systemd considers the service active.
The official systemctl documentation defines the status command as the way to inspect the current runtime state of a service unit.
Linux manual page
Step 13: Verify the active service state directly.
Execute:
systemctl is-active apache2
Expected output:
active
Check the exit status immediately afterward:
echo $?
Expected:
0
The service is considered active when systemctl is-active returns active with a successful exit status.
Step 14: Verify that Apache is listening for connections.
Execute:
sudo ss -ltnp | grep apache2
This should display Apache processes listening on the ports specified in its configuration, provided those sockets can be associated with the process in the command output.
Alternatively, check the configured HTTP port:
sudo ss -ltnp | grep ':80'
An illustrative successful result might include:
LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
The actual listening address and ports depend on Apache's configuration.
Step 15: Test the Apache HTTP service.
Execute:
curl -I http://localhost
This sends an HTTP HEAD request to the local web server.
An example of a successful HTTP response is:
HTTP/1.1 200 OK
Server: Apache/2.4.x (Ubuntu)
Content-Type: text/html
The exact response code depends on the website's configuration. For example, a redirect or authentication response can still show that Apache is accepting connections.
If the service is active but HTTP requests fail, inspect its listener configuration and logs.
Step 16: Confirm that the service remains running.
Execute:
sleep 5
systemctl is-active apache2
Expected:
active
This additional check helps detect a service that starts briefly and then fails.
You can also inspect recent logs:
sudo journalctl -u apache2 -n 20 --no-pager
Confirm that no further startup or runtime failures have occurred.
Step 17: Perform final verification.
Execute:
sudo apache2ctl configtest
systemctl is-active apache2
sudo systemctl status apache2 --no-pager
curl -I http://localhost
The final requirements are:
Verification
Expected result
Apache configuration test
Syntax OK
Apache executable permission
Valid executable permissions
systemd service status
active (running)
HTTP connectivity
A valid response from the configured service
Original startup failure
Resolved
Final Solution
The video suggests the failure may be related to execute permission on /usr/sbin/apache2. The following is the concise command sequence for that specific confirmed failure.
1. Connect to the server.
ssh lfcs00101a
2. Check the service failure.
sudo systemctl status apache2
sudo journalctl -u apache2 -n 50 --no-pager
3. Inspect the Apache executable permissions.
ls -l /usr/sbin/apache2
4. Restore executable permissions if they are incorrect.
sudo chmod 755 /usr/sbin/apache2
5. Validate the Apache configuration.
sudo apache2ctl configtest
6. Start the Apache service.
sudo systemctl start apache2
7. Verify the running service.
sudo systemctl status apache2
systemctl is-active apache2
Expected:
active
8. Verify HTTP connectivity.
curl -I http://localhost
Technical Verification and References
The procedures are consistent with official Apache and systemd documentation:
Apache HTTP Server — apachectl and configtest
Apache HTTP Server — Startup and Troubleshooting
Linux systemctl — Managing Service Units
systemd journalctl — Service Log Inspection
Expected result: The cause preventing apache2 from starting is corrected, and the service is successfully started with systemd and remains in the active (running) state.
Video verification finding: The candidate visibly runs sudo chmod +x /usr/sbin/apache2 and then attempts to restart Apache. That is a valid repair if missing executable permission was the actual fault, but the visible commands do not independently prove the diagnosis or final service state. The diagnostic and verification steps above are necessary for a reliable solution.
Context
You are asked to organize existing SSL certificates in the filesystem.
Task
Identify the subject CN of the SSL certificate in the directory ~/relaxed-llama/ssl and move the certificate file into the corresponding subdirectory.
The sub-directory for the subject CN has already been created.
The Answer Is:
See the complete solution in Explanation.
Explanation:
Step 1: Connect to the correct server.
The video specifies that this task must be completed on host lfcs00094.
From the candidate terminal, execute:
ssh lfcs00094
This establishes an SSH connection to the designated Linux server.
All subsequent commands must be executed on this host.
Step 2: Navigate to the SSL certificate directory.
Execute:
cd ~/relaxed-llama/ssl
- cd changes the current working directory.
- ~ represents the current user's home directory.
- relaxed-llama/ssl is the directory specified in the task.
Verify the current directory:
pwd
Then list the contents:
ls -la
The directory should contain an SSL certificate file and existing subdirectories corresponding to certificate common names.
Step 3: Identify the SSL certificate file.
Execute:
find . -maxdepth 1 -type f -print
- find . searches from the current directory.
- -maxdepth 1 restricts the search to the current directory.
- -type f identifies regular files.
- -print displays their paths.
An SSL certificate commonly uses an extension such as .crt, .pem, or .cer, although other filenames are possible.
For example, a directory might contain:
/server.crt
/alpha.example.com/
/bravo.example.com/
/charlie.example.com/
These are illustrative filenames, not confirmed contents of the exam server.
Identify the actual certificate filename before continuing.
Step 4: Examine the SSL certificate using OpenSSL.
Once you have identified the certificate, run:
openssl x509 -in CERTIFICATE_FILENAME -noout -subject
Replace CERTIFICATE_FILENAME with the real filename.
For example, if the file is named server.crt:
openssl x509 -in server.crt -noout -subject
- openssl invokes the OpenSSL utility.
- x509 processes an X.509 certificate.
- -in server.crt specifies the certificate file.
- -noout suppresses the encoded certificate output.
- -subject displays the certificate's subject distinguished name.
An illustrative result is:
subject=C = US, ST = California, O = Example Corp, CN = bravo.example.com
The important field is:
CN = bravo.example.com
CN stands for Common Name, an attribute of the certificate's subject.
The actual value must come from the certificate on the designated host.
Step 5: Display the subject CN clearly.
For easier identification, execute:
openssl x509 -in CERTIFICATE_FILENAME \
-noout -subject -nameopt sep_multiline
This prints the subject attributes on separate lines.
Example:
subject=
countryName = US
stateOrProvinceName = California
organizationName = Example Corp
commonName = bravo.example.com
The commonName value is the information required to select the correct destination subdirectory.
Do not confuse the certificate's subject CN with its issuer CN or the Subject Alternative Name extension. The task specifically asks for the subject CN.
Step 6: Locate the matching subdirectory.
List the existing directories:
find . -maxdepth 1 -type d -print
If the certificate's subject CN is bravo.example.com, its matching destination should be:
~/relaxed-llama/ssl/bravo.example.com/
Verify that the matching directory exists:
ls -ld ~/relaxed-llama/ssl/bravo.example.com
Again, bravo.example.com is an example. Substitute the actual CN reported by OpenSSL.
The task states that the subdirectory has already been created.
Therefore, do not create a new directory unless you have established that the supplied environment differs from the task statement.
Step 7: Move the certificate into the correct subdirectory.
The Linux command for moving a file is mv.
Its basic syntax is:
mv SOURCE_FILE DESTINATION_DIRECTORY/
For example, if:
- Certificate filename: server.crt
- Subject CN: bravo.example.com
The command would be:
mv server.crt bravo.example.com/
This moves the certificate from:
~/relaxed-llama/ssl/server.crt
to:
~/relaxed-llama/ssl/bravo.example.com/server.crt
The original filename is preserved.
Before moving the actual file, ensure that the destination does not already contain a different file with the same name. You can use mv -i to request confirmation before overwriting an existing destination.
Do not copy the certificate using cp, because the task specifically requires moving it.
Step 8: Verify that the certificate was moved successfully.
Execute:
ls -l bravo.example.com/
The output should show the certificate inside the directory matching its CN.
Verify that the certificate no longer exists in the original location:
ls -l server.crt
For the illustrative filename, the expected response is:
ls: cannot access 'server.crt': No such file or directory
This indicates the original path no longer contains the file.
Step 9: Verify that the moved certificate is readable and unchanged.
Execute:
openssl x509 \
-in bravo.example.com/server.crt \
-noout -subject
The certificate's subject CN should be identical to the value obtained before the move.
For example:
subject=C = US, ST = California, O = Example Corp, CN = bravo.example.com
This confirms that the certificate is still readable and is located inside the corresponding CN directory.
Step 10: Perform the final directory verification.
Execute:
find ~/relaxed-llama/ssl -maxdepth 2 -type f -print
Confirm that the certificate appears at the expected destination.
The final directory structure should resemble:
~/relaxed-llama/ssl/
├── alpha.example.com/
├── bravo.example.com/
│ └── server.crt
└── charlie.example.com/
This directory structure is illustrative. The actual destination must match the CN obtained from the real certificate.
Final Solution
The essential command sequence is:
1. Navigate to the directory.
cd ~/relaxed-llama/ssl
2. List the files and directories.
ls -la
3. Identify the certificate's subject CN.
openssl x509 -in CERTIFICATE_FILENAME \
-noout -subject -nameopt sep_multiline
4. Move the certificate into its matching existing CN directory.
mv CERTIFICATE_FILENAME CN_DIRECTORY/
5. Verify the destination.
ls -l CN_DIRECTORY/
6. Confirm the certificate's subject again.
openssl x509 -in CN_DIRECTORY/CERTIFICATE_FILENAME \
-noout -subject
Replace CERTIFICATE_FILENAME and CN_DIRECTORY with the actual values discovered on the server.
Technical Verification and References
The solution is based on the officially documented behavior of OpenSSL and the GNU/Linux mv command.
- OpenSSL X.509: The -subject option displays the certificate subject; -noout suppresses certificate output; and -nameopt controls the format of the subject information.
OpenSSL Documentation
- GNU Coreutils: The mv command moves a file into an existing target directory while preserving its filename unless a new filename is explicitly supplied.
Official documentation: OpenSSL X.509 Certificate Command Reference.
Expected result: The existing SSL certificate is moved into the already-created subdirectory whose name matches the certificate's subject CN.
Important: The video reveals the task requirements but does not establish the actual certificate filename or subject CN from the target server. Therefore, assigning a particular destination without inspecting the certificate would be an unverified guess. The procedure above determines the correct destination directly from the certificate.
Task
Schedule a cron job for user james that:
- runs every day at 17:15
- executes the script /home/james/bin/scanfiles.sh
- sends its STDOUT output to /home/james/report.txt
The Answer Is:
See the complete solution in Explanation.
Explanation:
Step 1: Connect to the correct server.
The video specifies that the task must be completed on host lfcs00082.
From the candidate terminal, connect using:
ssh lfcs00082
This establishes an SSH session with the server where the cron job must be configured.
Step 2: Verify that the user james exists.
Execute:
id james
This displays the user's UID, primary GID, and group memberships.
An example of valid output is:
uid=1001(james) gid=1001(james) groups=1001(james)
The exact numerical IDs may differ. The important requirement is that the user james exists.
Step 3: Verify that the script exists.
Execute:
ls -l /home/james/bin/scanfiles.sh
This verifies the script's location, ownership, and permissions.
You can also check whether james has execute permission:
sudo -u james test -x /home/james/bin/scanfiles.sh
echo $?
An exit status of 0 confirms that the user can execute the script. If the check fails, investigate file and directory permissions.
The task does not require creating or modifying the script.
Step 4: Open the crontab for user james.
Execute:
sudo crontab -u james -e
- sudo provides the privileges needed to manage another user's crontab.
- crontab manages scheduled cron jobs.
- -u james selects the crontab belonging to user james.
- -e opens the selected crontab in a text editor.
This is important because the task explicitly requires scheduling the job for james, not for root or the candidate account.
Step 5: Add the cron job.
Insert the following entry into the crontab:
15 17 * * * /home/james/bin/scanfiles.sh > /home/james/report.txt
This is the exact scheduling command required to satisfy the task.
Step 6: Understand the cron expression.
The cron entry contains five scheduling fields followed by the command.
Field Value Description
Minute 15 Execute at minute 15
Hour 17 Execute at 17:00 (5 PM)
Day of month * Every day of the month
Month * Every month
Day of week * Every day of the week
Therefore, the script executes once daily at 17:15 according to the cron daemon's configured timezone.
The command portion is:
/home/james/bin/scanfiles.sh > /home/james/report.txt
It consists of:
- /home/james/bin/scanfiles.sh — the executable script.
- > — the shell's STDOUT redirection operator.
- /home/james/report.txt — the destination file for standard output.
The > operator creates the report file if it does not exist and the user has permission. If it exists, the output is overwritten on each execution.
Do not replace > with > > because > > appends output. Also, do not use 2 > & 1, because the task requests STDOUT only, not STDERR.
Step 7: Save the crontab.
If the crontab opens in Vim:
1. Press i to enter insert mode.
2. Add the cron entry.
3. Press Esc.
4. Type :wq and press Enter.
If it opens in Nano, press Ctrl+O, Enter, then Ctrl+X.
Once saved, the crontab command installs the updated schedule automatically.
Step 8: Verify the installed cron job.
Execute:
sudo crontab -u james -l
The output must include:
15 17 * * * /home/james/bin/scanfiles.sh > /home/james/report.txt
This verifies that the job is installed under the correct user account.
Step 9: Check the cron service.
On the Ubuntu system shown in the recording, execute:
systemctl status cron
The service should report:
Active: active (running)
If it is inactive, start it:
sudo systemctl start cron
To check whether the service is enabled for startup:
systemctl is-enabled cron
If cron is disabled and must remain operational after reboot, enable it:
sudo systemctl enable cron
Step 10: Verify the final configuration.
Run:
sudo crontab -u james -l
sudo -u james test -x /home/james/bin/scanfiles.sh
systemctl is-active cron
These commands verify that:
1. The required cron entry belongs to james.
2. The script is executable by james.
3. The cron service is active.
The report file is not necessarily present immediately after installing the cron entry. It will be created or overwritten when the scheduled job executes successfully.
Final Solution
The essential command is:
sudo crontab -u james -e
Add:
15 17 * * * /home/james/bin/scanfiles.sh > /home/james/report.txt
Then verify:
sudo crontab -u james -l
Technical verification: This solution follows the documented Linux crontab(1) and crontab(5) syntax. A user-specific crontab executes commands under the owner's account and uses five scheduling fields followed by the command.
Linux manual page
+1
Expected result: The script runs every day at 17:15 as james, directing its standard output to /home/james/report.txt. The schedule's configuration is verified; actual runtime success depends on the script, its permissions, and the target system.
Task
In the Git repository cloned to ~/optimal-bedbug, edit the file hosts. Uncomment all the host entries in the group [webservers].
Finally, commit the change in file hosts using the commit message Enables missing hosts and push the commit to the remote.
The Answer Is:
See the complete solution in Explanation.
Explanation:
Step 1: Connect to the correct Linux server.
The video specifies that this task must be completed on host lfcs00100.
From the candidate terminal, execute:
ssh lfcs00100
This establishes an SSH connection to the designated server.
All remaining commands must be executed on this host.
Step 2: Navigate to the existing Git repository.
Execute:
cd ~/optimal-bedbug
- cd changes the current directory.
- ~ refers to the current user's home directory.
- optimal-bedbug is the existing Git repository specified in the task.
Verify the current working directory:
pwd
List the repository contents:
ls -la
Check whether it is a valid Git repository:
git rev-parse --show-toplevel
The output should identify the root directory of optimal-bedbug.
The repository is already cloned. Therefore, there is no requirement to execute git init or git clone.
Step 3: Inspect the repository status.
Execute:
git status
This displays the current branch, modified files, staged changes, and working tree status.
Also execute:
git branch --show-current
This identifies the active branch.
Check the configured remote:
git remote -v
An example output might be:
origin git@example.com:training/optimal-bedbug.git (fetch)
origin git@example.com:training/optimal-bedbug.git (push)
The remote URL is illustrative. Use the remote already configured in the existing repository.
Do not modify unrelated repository configuration.
Step 4: Locate and inspect the hosts file.
Execute:
ls -l hosts
Display its complete contents:
cat hosts
The task requires editing the file named hosts in the repository.
Locate the section:
[webservers]
This is an inventory-style group heading.
The entries belonging to [webservers] appear below the heading and continue until the next group heading or the end of the file.
Step 5: Identify the commented host entries.
To display the [webservers] section, execute:
awk '
/^\[webservers\]$/ {inside=1; print; next}
/^\[/ {inside=0}
inside {print}
' hosts
- awk processes the file line by line.
- /^\[webservers\]$/ identifies the exact group heading.
- inside=1 enables output for the selected group.
- /^\[/ identifies a subsequent group heading.
- inside=0 stops output when another group begins.
- inside {print} displays entries belonging to [webservers].
Look for host entries beginning with #.
For illustration, the original section might look like:
[webservers]
#192.168.10.11
#192.168.10.12
192.168.10.13
#192.168.10.14
[dbservers]
#192.168.20.11
192.168.20.12
These addresses are examples only. Preserve the actual addresses and hostnames found in the video environment.
The task requires uncommenting all host entries in [webservers] only.
Step 6: Edit the hosts file.
Open the file using Nano:
nano hosts
Alternatively, use Vim:
vim hosts
Navigate to:
[webservers]
Remove the leading comment character # from every commented host entry in that group.
For example:
Before:
[webservers]
#192.168.10.11
#192.168.10.12
192.168.10.13
#192.168.10.14
[dbservers]
#192.168.20.11
192.168.20.12
After:
[webservers]
192.168.10.11
192.168.10.12
192.168.10.13
192.168.10.14
[dbservers]
#192.168.20.11
192.168.20.12
Important requirements:
- Remove # only from commented host entries belonging to [webservers].
- Do not remove the [webservers] group heading.
- Do not change the IP addresses or hostnames.
- Do not uncomment entries belonging to other groups.
- Do not remove comments that are descriptive notes rather than host entries.
- Preserve the original file structure and unrelated content.
Step 7: Save the modified file.
If using Nano:
1. Press Ctrl + O.
2. Press Enter to save.
3. Press Ctrl + X to exit.
If using Vim:
1. Press Esc.
2. Type :wq.
3. Press Enter.
Step 8: Verify the changes before committing.
Execute:
git diff -- hosts
This displays the difference between the working version of hosts and its previous Git version.
For example:
[webservers]
-#192.168.10.11
-#192.168.10.12
+192.168.10.11
+192.168.10.12
192.168.10.13
-#192.168.10.14
+192.168.10.14
- Lines beginning with - were removed from the previous file version.
- Lines beginning with + were added.
- Unprefixed context lines are unchanged.
Confirm that the differences are limited to the requested modifications.
If unrelated lines have changed accidentally, correct them before proceeding.
Step 9: Stage the modified hosts file.
Execute:
git add hosts
git add places the current file contents into Git's staging area, also called the index.
This prepares the modification for the next commit.
Do not use:
git add .
because it stages all changed files under the current directory, potentially including unrelated modifications.
The task specifically concerns the hosts file.
Step 10: Verify the staged changes.
Execute:
git diff --cached -- hosts
This shows the changes staged for the commit.
Also check:
git diff --cached --name-only
Ideally, the only staged file should be:
hosts
If unrelated changes were previously staged, avoid including them in this task's commit.
Step 11: Commit the changes using the exact required message.
Execute:
git commit -m "Enables missing hosts"
- git commit creates a new commit from the staging area.
- -m provides the commit message directly.
- "Enables missing hosts" is the exact message specified in the task.
Do not change the spelling or capitalization.
A successful commit may produce output similar to:
[main a1b2c3d] Enables missing hosts
1 file changed, 3 insertions(+), 3 deletions(-)
The branch name, commit hash and change count will depend on the actual repository.
If unrelated changes are already staged, use the file-specific commit operation instead:
git commit --only -m "Enables missing hosts" -- hosts
This creates a commit containing the selected file's modification rather than unrelated staged files.
Step 12: Verify that the commit was created.
Execute:
git log -1 --oneline
The most recent commit should have the required message.
For example:
a1b2c3d Enables missing hosts
Check which files were included in the commit:
git show --stat --oneline HEAD
The commit should contain the requested modification to hosts.
You can inspect the full commit:
git show --format=fuller HEAD -- hosts
This confirms the exact lines committed.
Step 13: Push the commit to the remote repository.
Execute:
git push
The git push command transfers local commits to the configured remote repository and updates the destination branch.
If the current branch already tracks a remote branch, this should be sufficient.
A successful push may display output similar to:
To git@example.com:training/optimal-bedbug.git
123abcd..a1b2c3d main - > main
If Git reports that no upstream branch is configured, first inspect:
git remote -v
git branch --show-current
If the intended remote is origin, execute:
git push -u origin HEAD
- -u configures upstream tracking for the successfully pushed branch.
- origin specifies the destination remote.
- HEAD refers to the current local branch.
Do not use git push --force. Force-pushing can overwrite remote history and is not required by this task.
Git's official documentation confirms that git push updates remote references and that --set-upstream configures branch tracking.
git-push Documentation
Step 14: Verify that the push completed successfully.
Execute:
git status -sb
Inspect the branch's tracking relationship and whether any commits remain ahead of the remote-tracking branch.
Next:
git branch -vv
This displays the local branches and their upstream tracking information.
To check whether your latest commit has reached the configured upstream, execute:
git rev-parse HEAD
git rev-parse '@{upstream}'
For a straightforward successful push of the current branch, both hashes should normally be identical.
You can also check whether any local commits remain unpushed:
git log '@{upstream}..HEAD' --oneline
If it produces no output, the local branch contains no commits ahead of its upstream tracking reference.
A clean working tree alone does not prove a successful push. The remote update must succeed separately.
Step 15: Perform the final verification.
Execute:
cd ~/optimal-bedbug
git status
git log -1 --oneline
git show --format= --name-only HEAD
git branch -vv
Then inspect the [webservers] section again:
awk '
/^\[webservers\]$/ {inside=1; print; next}
/^\[/ {inside=0}
inside {print}
' hosts
Confirm that all required host entries are uncommented.
Final Solution
Essential commands in execution order
Copy commands
ssh lfcs00100
cd ~/optimal-bedbug
# Examine the repository and inventory
git status
cat hosts
# Edit the file
nano hosts
# Uncomment all host entries under [webservers]
# Save and close the editor
# Review the changes
git diff -- hosts
# Stage the modified file
git add hosts
# Verify staged changes
git diff --cached -- hosts
# Commit using the exact message
git commit -m "Enables missing hosts"
# Push to the configured remote
git push
# Final verification
git log -1 --oneline
git status -sb
Technical Verification and References
The solution has been checked against the official Git documentation.
- Git add: Adds modified file contents to the staging area in preparation for a commit.
GitHub
- Git commit: Records staged modifications as a new commit using the specified commit message.
git-commit Documentation
- Git push: Transfers commits to the configured remote repository and updates remote branch references.
git-push Documentation
Official documentation: Git Command Reference.
Expected result: All host entries within [webservers] in ~/optimal-bedbug/hosts are uncommented. The modification is committed with the exact message Enables missing hosts, and the new commit is successfully pushed to the remote repository.