Searching for workable clues to ace the Linux Foundation LFCS Exam? You’re on the right place! ExamCert has realistic, trusted and authentic exam prep tools to help you achieve your desired credential. ExamCert’s LFCS PDF Study Guide, Testing Engine and Exam Dumps follow a reliable exam preparation strategy, providing you the most relevant and updated study material that is crafted in an easy to learn format of questions and answers. ExamCert’s study tools aim at simplifying all complex and confusing concepts of the exam and introduce you to the real exam scenario and practice it with the help of its testing engine and real exam dumps
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.
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.
Task
First, build the Dockerfile located at ~/flying-jay/Dockerfile, tagging the container image as myapp:latest.
Next, start a detached container using the built image tagged myapp:latest, mapping the container port 80/tcp to host port 8080/tcp and limiting the memory usage to 256m.
Finally, ensure that the container is started automatically on boot or restart of Docker.
Objective: Build a Docker image from the existing Dockerfile, create and start a container in detached mode, configure its network port mapping and memory limit, and ensure Docker automatically restarts the container following a Docker daemon restart or system reboot.
The task requires four specific configurations:
Requirement
Correct configuration
Docker image
myapp:latest
Container execution
Detached (-d)
Port mapping
Host 8080/tcp → Container 80/tcp
Memory limit
256m
Automatic restart
--restart=always
The essential Docker commands are:
Docker's official documentation confirms the behavior of the image-building, container-execution, memory-limit, port-publishing and restart-policy options used here.
Docker Docs
+2
Step 1: Connect to the correct Linux server.
The video specifies host lfcs00096.
From the candidate terminal, execute:
This connects to the Linux host where the Docker image and container must be created.
All subsequent commands must be executed on this host.
Step 2: Verify that Docker is installed.
Execute:
This displays the installed Docker client version.
For example:
The actual version may differ.
Check whether the Docker daemon is accessible:
This reports information about the Docker Engine, including its version, storage driver, available resources and container runtime.
If the Docker daemon is unavailable, investigate the service before proceeding.
Step 3: Verify that the Docker service is running.
Execute:
A running service should report:
For a concise check:
Expected:
If Docker is installed but stopped, start it:
There is no reason to reinstall Docker if the existing installation is functioning.
Step 4: Navigate to the Dockerfile directory.
The task specifies:
Execute:
Verify the working directory:
Then inspect its contents:
The directory should contain the Dockerfile and any files required to build the application.
Step 5: Verify that the Dockerfile exists.
Execute:
You can also confirm that it is a regular file:
An exit status of 0 indicates that the file exists.
The Dockerfile is already provided. There is no requirement to create a new Dockerfile or replace its contents.
Step 6: Inspect the Dockerfile before building.
Execute:
A Dockerfile can contain instructions such as:
Instruction
Purpose
FROM
Specifies the base image
RUN
Executes commands during image creation
COPY
Copies files from the build context into the image
WORKDIR
Sets the working directory
EXPOSE
Documents an intended container listening port
CMD
Specifies a default startup command
ENTRYPOINT
Defines the executable launched by the container
The Dockerfile may already configure a web service to listen on port 80.
Do not invent or replace application commands, because the task requires building the existing Dockerfile.
Step 7: Understand the Docker build context.
The Docker build context is the collection of files available to the Docker builder.
Because the Dockerfile is located at:
the normal build context is:
After navigating into that directory, the build context is represented by:
Docker's official documentation confirms that the final positional argument of docker build defines the build context.
Docker Docs
Step 8: Build the Docker image with the exact required tag.
Execute:
This is the first essential Docker command.
sudo provides access to the Docker daemon.
docker build builds an image from a Dockerfile.
-t assigns a repository name and image tag.
myapp:latest is the exact image reference specified in the task.
indicates the current directory as the build context.
An equivalent command, when executed from another directory, would be:
However, the shorter command is preferable after changing into ~/flying-jay.
Step 9: Examine the build output.
During the build, Docker processes the Dockerfile instructions.
A successful build may display output similar to:
This is illustrative.
The actual build output depends on the contents of the Dockerfile, Docker Engine version and BuildKit configuration.
After the command completes, check the exit status:
Expected:
If the build fails, inspect the reported error before proceeding. Common causes include an unavailable base image, missing build-context files or a failing Dockerfile instruction.
Step 10: Verify that the image was created successfully.
Execute:
The output should contain an entry corresponding to:
For more specific verification:
If the image exists, Docker returns its metadata.
If the image does not exist, Docker reports an error.
Do not create a container until the image has been built successfully.
Step 11: Check whether an existing container will conflict.
The task does not specify a required container name. For easier management, the solution will use:
Before creating the container, execute:
Check whether a container named myapp already exists.
If an existing container has that name, inspect it rather than automatically deleting it. Docker container names must be unique.
Using --name myapp is optional for the assessment; it is a convenient identifier for verification.
Step 12: Start the container in detached mode with all required options.
Execute:
This is the second essential command and implements all requested runtime requirements.
Parameter
Purpose
docker run
Creates and starts the container
-d
Runs the container in detached mode
--name myapp
Assigns a convenient container name
--restart=always
Configures automatic restarts
-p 8080:80/tcp
Maps host TCP 8080 to container TCP 80
--memory=256m
Sets a 256 MiB memory limit
myapp:latest
Uses the required Docker image
Docker documents all these options as supported container-runtime settings.
Docker Docs
Step 13: Understand detached mode.
The -d option means detached mode.
When executed with -d, Docker starts the container in the background and returns control to the terminal.
For example:
does not attach the terminal to the container's standard input and output.
Instead, Docker normally prints the new container ID.
The task explicitly requests a detached container, so do not omit -d.
Also, do not use --rm for this task. Removing a container automatically on exit conflicts with the intended persistent container lifecycle.
Step 14: Understand the required port mapping.
The task states:
mapping the container port 80/tcp to host port 8080/tcp
The correct argument is:
Docker port-publishing syntax is:
Therefore:
A connection to:
is forwarded to TCP port 80 inside the container.
Do not reverse the numbers:
That would map host port 80 to container port 8080, which is the opposite of the task's requirement.
By default, publishing without a specific host IP address exposes the port on the Docker host's available network interfaces, subject to network and firewall configuration.
Docker Docs
Step 15: Understand the 256m memory limit.
The required option is:
This configures a hard limit on the container's physical memory usage.
Docker interprets this memory size as:
256
×
1024
×
1024
=
268
,
435
,
456
bytes
256×1024×1024=268,435,456 bytes
Therefore, the configured memory value is:
The memory limit is enforced through Linux kernel resource-management mechanisms, such as control groups (cgroups).
One distinction matters: --memory=256m limits physical memory, but Docker may permit additional swap usage depending on its swap configuration.
The task does not separately specify a swap limit. Therefore, --memory=256m is the appropriate requested setting without introducing unrelated swap restrictions.
Docker Docs
Step 16: Understand automatic container restart behavior.
The final requirement is:
Finally, ensure that the container is started automatically on boot or restart of Docker.
Docker supports several restart policies.
Restart policy
Behavior
no
No automatic restart
on-failure
Restart after a failed process exit, subject to options
always
Restart when the container exits and after applicable Docker daemon restarts
unless-stopped
Similar to always, but retains a manually stopped state across daemon restarts
For this task, use:
This is appropriate because the task specifically requires automatic startup after boot or a Docker daemon restart.
Docker documents that a manually stopped container using always is normally restarted when the Docker daemon restarts, unlike unless-stopped.
Docker Docs
Step 17: Verify that the container was created and started.
Execute:
A successful result should include a container using:
Its status should indicate that it is running.
For example:
This is an illustrative result.
If no running container appears, inspect stopped containers:
A successful docker run -d response only confirms that Docker accepted the startup request; it does not guarantee the application continues running.
Step 18: Verify the image used by the container.
Execute:
Expected:
This confirms that the running container was created using the required image reference.
Docker's official inspect documentation supports using formatted output to retrieve individual container configuration fields.
Docker Docs
Step 19: Verify the container's TCP port mapping.
Execute:
Expected output includes a mapping equivalent to:
Depending on the host configuration, Docker may also display an IPv6 mapping.
For a targeted check:
This should identify host TCP port 8080.
The docker port command is specifically documented for inspecting published port mappings.
Docker Docs
Step 20: Verify the configured memory limit.
Execute:
Expected:
This confirms the configured 256 MiB limit.
You can also examine runtime resource usage:
This displays the current memory consumption and configured memory limit.
An illustrative result might show:
The actual usage depends on the application.
Step 21: Verify the automatic restart policy.
Execute:
Expected output:
This confirms that the Docker container has the required restart policy.
If an otherwise correctly configured container was created without that setting, the restart policy can be corrected using:
There is no need to recreate the container solely to change its restart policy.
Docker Docs
Step 22: Ensure Docker itself starts at boot.
A container restart policy works when the Docker daemon is running.
Check whether the Docker service is enabled:
Expected:
On Ubuntu, Docker is commonly enabled to start automatically at boot.
If it is disabled, execute:
Where containerd.service is installed and is part of the Docker Engine setup, verify that its startup configuration is appropriate as well.
Docker's official Linux post-installation documentation recommends enabling Docker and containerd services for boot-time startup on systemd-based systems when they are not already enabled.
Docker Docs
Step 23: Test the application through host port 8080.
If the Dockerfile starts an HTTP application on port 80, execute:
A valid HTTP response confirms that the host's published port can reach the containerized application.
For example:
The actual response code depends on the application's configuration.
An HTTP response is an application-level test. The Docker task itself requires the port mapping to be configured correctly, so do not confuse an application error with an incorrect port-publishing setting without further investigation.
Step 24: Troubleshoot a container that exits unexpectedly.
If the container does not remain running, execute:
Check its current state.
Then inspect its logs:
Common causes of immediate container exit include:
An invalid startup command.
A missing application dependency.
An application configuration error.
Failure of the image's main process.
Memory exhaustion.
Do not assume that --restart=always repairs application failures.
Docker's restart policy takes effect after a container has started successfully, with Docker documenting a minimum successful startup period of approximately ten seconds before restart monitoring applies.