Curated

Services and User Management

0 votes

Questions133

  1. Question 101

    Services and User Management

    An application image requires twelve settings, stored one per line as KEY=value in /etc/myapp/app.env on the host. Which command starts the container with all twelve set as environment variables?

    Show the answer

    Correct answerD. podman run -d --env-file /etc/myapp/app.env myapp:2.0

    --env-file reads KEY=value lines from a file and sets each as an environment variable in the container. --label-file looks similar but only applies metadata labels, so the application never sees the values as variables.

    Open this question
  2. Question 102

    Services and User Management

    A container named web01 is still running and must be deleted immediately with a single command. The image it was created from must be kept. Which command does this?

    Show the answer

    Correct answerC. docker rm -f web01

    docker rm -f force-removes a container even while it is running, and it leaves the image in place. A plain docker rm refuses to delete a running container, so it fails here, and docker rmi targets images, not containers.

    Open this question
  3. Question 103

    Services and User Management

    A container named app01 exited unexpectedly overnight. An administrator wants only its exit code to decide how to proceed. Which command returns that value?

    Show the answer

    Correct answerA. docker inspect -f '{{.State.ExitCode}}' app01

    docker inspect with a Go template on .State.ExitCode prints the stored exit status of a stopped container. docker logs shows only the output the process wrote, which may not contain the code, and docker top only works on running containers.

    Open this question
  4. Question 104

    Services and User Management

    The variable DB_HOST is exported in an administrator's shell with the value db.internal. The administrator wants a new container to start with DB_HOST=db.internal in its environment. Which two commands achieve this? (Choose two.)

    Choose 2 answers

    Show the answer

    Correct answersA. podman run -e DB_HOST myapp:2.0D. podman run --env DB_HOST=db.internal myapp:2.0

    -e with only a name copies the value from the calling shell, and --env with KEY=value sets it explicitly. --env-file expects a file path, so DB_HOST would be read as a filename and fail. --build-arg applies to image builds, not to run.

    Open this question
  5. Question 105

    Services and User Management

    A container named web01 is serving traffic. An administrator needs a new interactive Bash shell inside it to review configuration files, without interrupting the web server process. Which command accomplishes this?

    Show the answer

    Correct answerA. docker exec -it web01 /bin/bash

    docker exec starts an additional process, here a shell, inside a running container and leaves the main process untouched. docker attach only connects to the main process's streams and gives no new shell, and exiting it can disrupt the service.

    Open this question
  6. Question 106

    Services and User Management

    An administrator created a named volume with the command podman volume create appdata. A new nginx container must mount that existing volume at /data inside the container and must not be able to write to it. Which command does this?

    Show the answer

    Correct answerC. podman run -d -v appdata:/data:ro nginx

    The -v syntax is source:destination:options, so appdata:/data:ro maps the named volume to /data read-only. The bind mount type treats src as a host path; appdata is not a host path, so that command fails instead of using the volume.

    Open this question
  7. Question 107

    Services and User Management

    An administrator is working with named volumes in Podman. Which four statements are correct? (Choose four.)

    Choose 4 answers

    Show the answer

    Correct answersB. Data written to webdata remains available after the container that wrote it is removed.C. Running podman volume create webdata creates a named volume that Podman manages.D. Running podman run -v webdata:/var/www/html mounts the volume at that path inside the container.E. Running podman volume inspect webdata shows the mount point of the volume on the host.

    AWhy not this: podman rm leaves named volumes in place; they are removed only with podman volume rm or prune.

    BWhy this is right: A named volume exists independently of containers, so its data survives container removal.

    CWhy this is right: Podman volume create makes a named volume that Podman manages.

    DWhy this is right: -v webdata:/var/www/html mounts the named volume at that path in the container.

    EWhy this is right: Podman volume inspect shows the volume's details, including its Mountpoint on the host.

    FWhy not this: prune removes only volumes that no container uses; volumes in use are kept.

    Named volumes are created, mapped with -v name:path, inspected for their host mount point, and persist independently of containers. Removing a container does not delete its named volumes; they go only through podman volume rm or podman volume prune, and prune removes only volumes no container uses.

    Open this question
  8. Question 108

    Services and User Management

    On a RHEL server with SELinux enforcing, an administrator starts a rootless Podman container with the bind mount -v /srv/site:/usr/share/nginx/html. The web server returns permission denied, and the audit log shows an AVC denial. The /srv/site directory carries the default var_t type. Which change BEST fixes the problem while keeping SELinux enforcing?

    Show the answer

    Correct answerD. Append :Z to the volume option so Podman relabels the directory with container_file_t

    The :Z option makes Podman relabel the host directory with container_file_t (private to that container), which SELinux allows containers to access. Changing file permissions with chmod does not affect an SELinux type denial, so the AVC denial would continue.

    Open this question
  9. Question 109

    Services and User Management

    A container must write uploaded files to the existing host directory /srv/uploads so the files persist on the host. Inside the container the application uses /var/uploads. Which option maps the host directory to that path?

    Show the answer

    Correct answerD. -v /srv/uploads:/var/uploads

    A source beginning with / is a host path, so -v /srv/uploads:/var/uploads bind mounts that directory at /var/uploads. Using a bare name such as uploads creates or uses a named volume in Podman's storage, not the host directory.

    Open this question
  10. Question 110

    Services and User Management

    Two containers on a RHEL host with SELinux enforcing must both read and write /srv/shared. The first container was started with the option -v /srv/shared:/data:Z. When the second container starts with the same option, the first container loses access. SELinux separation must stay enabled. What should the administrator do?

    Show the answer

    Correct answerC. Mount the directory with :z in both containers so it gets a shared container_file_t label

    The lowercase :z option applies a shared container_file_t label that multiple containers can access. Uppercase :Z applies a private label for one container, so each new relabel locks out the previous one; restorecon would only restore the default label.

    Open this question
  11. Question 111

    Services and User Management

    An administrator has created a user-defined bridge network named appnet. A web server must run in the background on that network, and clients on the LAN must reach it by connecting to port 8080 on the Docker host. The web server listens on port 80 inside the container. Which command meets this requirement?

    Show the answer

    Correct answerB. docker run -d --network appnet -p 8080:80 nginx

    The -p option uses host_port:container_port, so 8080:80 publishes container port 80 on host port 8080. Reversing the values, as in 80:8080, would publish container port 8080 on host port 80, which does not match the web server's listening port.

    Open this question
  12. Question 112

    Services and User Management

    A containerized application must appear on the physical LAN as a separate device with its own IP address and its own unique MAC address, so that a legacy monitoring tool can identify it. Which Docker network driver BEST meets this requirement?

    Show the answer

    Correct answerC. macvlan

    The macvlan driver assigns each container its own MAC address and a LAN-routable IP, so it looks like a physical device. The ipvlan driver is similar, but containers share the parent interface's MAC address, so it does not meet the unique-MAC requirement.

    Open this question
  13. Question 113

    Services and User Management

    A team runs containers on three Docker hosts joined in a Swarm. Containers for a service on different hosts must communicate privately with each other by service name over a single logical network. Which network type should they use?

    Show the answer

    Correct answerB. overlay

    The overlay driver builds a distributed network across multiple Docker hosts, letting containers on different hosts communicate as if on one network. The bridge driver is limited to a single host, so containers on separate hosts cannot reach each other through it.

    Open this question
  14. Question 114

    Services and User Management

    An administrator creates a user-defined bridge network with docker network create appnet and attaches several containers to it. Which three statements are correct? (Choose three.)

    Choose 3 answers

    Show the answer

    Correct answersA. Containers on appnet can reach each other on any port they listen on without publishing those ports with -p.B. Containers on appnet can resolve each other by container name.D. Using -p 5353:53/udp publishes a UDP port, because publishing defaults to TCP when no protocol is given.

    AWhy this is right: Containers on the same user-defined bridge talk directly; -p only exposes ports to the host.

    BWhy this is right: Docker's embedded DNS resolves container names on user-defined networks.

    CWhy not this: With --network host the container uses the host's stack, so -p is ignored and nothing is remapped.

    DWhy this is right: Published ports default to TCP, so /udp is needed for a UDP port.

    EWhy not this: Embedded DNS resolves names only within the same user-defined network, not across to the default bridge.

    FWhy not this: docker network rm refuses a network that still has containers attached; it never removes containers.

    Containers on the same user-defined bridge reach each other directly and resolve names through Docker's embedded DNS, and /udp selects UDP over the TCP default. With host networking the container shares the host's network stack, so -p mappings do not apply and no remapping occurs. Name resolution works only within a user-defined network, and docker network rm refuses a network that still has containers attached.

    Open this question
  15. Question 115

    Services and User Management

    A PostgreSQL container must be reachable on port 5432 only by processes running on the Docker host itself. It must not be reachable from other machines on the network. Which option publishes the port correctly?

    Show the answer

    Correct answerD. -p 127.0.0.1:5432:5432

    Putting the loopback address first in the mapping (ip:host_port:container_port) binds the published port to 127.0.0.1 only. A plain 5432:5432 mapping binds to all host interfaces, which would expose the database to the network.

    Open this question
  16. Question 116

    Services and User Management

    An administrator starts a web server container with rootless Podman as a regular user. The container fails with a permission denied error when binding host port 80. The administrator wants to fix this without giving the container more host privileges. What should the administrator do?

    Show the answer

    Correct answerB. Publish the container on a host port above 1023, such as -p 8080:80

    Unprivileged users cannot bind to ports below 1024 by default, so publishing on a higher host port avoids the restriction without extra privilege. Adding --privileged does not give a rootless container host root rights, and it weakens isolation.

    Open this question
  17. Question 117

    Services and User Management

    A team runs a third-party image on a shared Linux server. Security policy requires that if a process breaks out of the container, it must not gain root privileges on the host. Which configuration BEST meets this requirement?

    Show the answer

    Correct answerB. Run the container rootless as a regular user so container root maps to an unprivileged host UID

    A rootless (unprivileged) container uses a user namespace, so root inside maps to a non-root host UID and an escape yields only that user's rights. A read-only filesystem does not help, because --privileged removes most confinement and exposes host devices.

    Open this question
  18. Question 118

    Services and User Management

    An administrator deleted a 20 GB log file that a running daemon still has open. df still shows the space as used. Which command lists open files that have been deleted (link count below one)?

    Show the answer

    Correct answerC. lsof +L1

    lsof +L1 lists open files with a link count under one, meaning deleted files still held open by a process. lsof +D /var/log is tempting, but a deleted file no longer has a path in that directory, so it is not listed.

    Open this question
  19. Question 119

    Services and User Management

    An administrator must compare /etc/app with its backup in /backup/app, including all subdirectories, and report only the names of files that differ. Which command does this?

    Show the answer

    Correct answerA. diff -rq /etc/app /backup/app

    diff -r recurses into subdirectories and -q reports only that files differ, not how. sdiff is tempting but it compares two files side by side and does not recurse through directories.

    Open this question
  20. Question 120

    Services and User Management

    A downloaded file named report.pdf is suspected to be a different type of file than its extension suggests. The administrator must confirm its actual content type and also display its inode number and size. Which two commands provide this information? (Choose two.)

    Choose 2 answers

    Show the answer

    Correct answersA. file report.pdfB. stat report.pdf

    file identifies the type by examining content, and stat shows the file's inode number and size. stat -f is tempting but reports on the filesystem holding the file, and ls -l shows size but neither inode nor content type.

    Open this question
  21. Question 121

    Services and User Management

    An administrator must move all .conf files from /tmp/new to /etc/app. Files with the same name that already exist in /etc/app must not be overwritten, and the command must run in a script without prompting. Which command does this?

    Show the answer

    Correct answerA. mv -n /tmp/new/*.conf /etc/app/

    The -n option never overwrites an existing destination file and does not prompt. The -u option is tempting, but it still replaces destination files that are older than the source.

    Open this question
  22. Question 122

    Services and User Management

    An administrator must list regular files under /var/log that are larger than 100 MiB and were modified within the last 7 days. Which command does this?

    Show the answer

    Correct answerD. find /var/log -type f -size +100M -mtime -7

    -size +100M matches files over 100 MiB and -mtime -7 matches files modified less than 7 days ago. Using +7 for -mtime is tempting but selects files modified more than 7 days ago.

    Open this question
  23. Question 123

    Services and User Management

    An administrator is connected to a server over SSH and must run ./backup.sh so that it survives a dropped connection. Its output must go to /tmp/backup.log, and the shell prompt must be available right away. Which command meets these requirements?

    Show the answer

    Correct answerA. nohup ./backup.sh > /tmp/backup.log 2>&1 &

    nohup makes the script ignore SIGHUP when the SSH session ends, and the trailing & returns the prompt immediately. Without nohup, the backgrounded job can still receive SIGHUP from the closing shell. Without &, the job survives but holds the terminal.

    Open this question
  24. Question 124

    Services and User Management

    A user's shell shows these jobs: [1] Running ./sync.sh &, [2]- Stopped vim notes.txt, and [3]+ Stopped ./report.sh. The user wants to resume editing in the stopped vim session in the foreground. Which command does this?

    Show the answer

    Correct answerD. fg %2

    fg %2 brings job 2, the stopped vim session, to the foreground and resumes it. A plain fg acts on the current job marked +, which is report.sh, not vim. bg %2 would resume vim in the background, where it would just stop again waiting for terminal input.

    Open this question
  25. Question 125

    Services and User Management

    A CI server must install Node.js dependencies for a project from a clean node_modules directory. The versions must match package-lock.json exactly, and the job must fail if the lock file and package.json disagree. Which command should the pipeline run?

    Show the answer

    Correct answerB. npm ci

    npm ci removes node_modules, installs the exact versions in package-lock.json and fails if the lock file and package.json are out of sync. npm update is tempting but moves packages to newer versions allowed by the version ranges, which breaks reproducibility.

    Open this question
  26. Question 126

    Services and User Management

    An administrator installs a downloaded .deb file on an Ubuntu server with dpkg -i. The command fails with unmet dependency errors, and the package is left unconfigured. Which command BEST fetches the missing dependencies from the configured repositories and completes the installation?

    Show the answer

    Correct answerC. sudo apt install -f

    apt install -f (--fix-broken) downloads the missing dependencies from the repositories and finishes configuring the package. dpkg --configure -a only configures already unpacked packages and does not fetch anything, so the missing dependencies stay unresolved.

    Open this question
  27. Question 127

    Services and User Management

    A technician must apply available updates to already installed packages on three servers running Ubuntu, RHEL 9 and openSUSE. Which three commands do this? (Choose three.)

    Choose 3 answers

    Show the answer

    Correct answersA. sudo zypper updateB. sudo apt upgradeC. sudo dnf upgrade

    AWhy this is right: zypper update installs newer versions of installed packages on openSUSE.

    BWhy this is right: apt upgrade installs newer versions of installed packages on Ubuntu.

    CWhy this is right: dnf upgrade installs newer versions of installed packages on RHEL 9.

    DWhy not this: apt update only refreshes the package index; it installs nothing.

    EWhy not this: dnf check-update only lists packages with updates available; it installs nothing.

    FWhy not this: zypper refresh only refreshes repository metadata; it installs nothing.

    apt upgrade, dnf upgrade and zypper update each install newer versions of installed packages. apt update is tempting but only refreshes the repository package index and installs nothing. Likewise dnf check-update only lists available updates, and zypper refresh only refreshes repository metadata.

    Open this question
  28. Question 128

    Services and User Management

    An administrator compiles a utility from a source tarball. The distribution already ships an older version of the utility in /usr/bin, and the new build must be installed under /opt/tool without overwriting it. Which step achieves this?

    Show the answer

    Correct answerD. Run ./configure --prefix=/opt/tool before make

    The installation prefix is set when the build is configured, so ./configure --prefix=/opt/tool makes make install place files under /opt/tool. make has no --prefix option, and ldconfig only updates the shared library cache; it does not choose where files are installed.

    Open this question
  29. Question 129

    Services and User Management

    After a vendor tool is copied to a RHEL 9 server, it fails with "error while loading shared libraries: libfoo.so.2: cannot open shared object file". The administrator does not know which package supplies the library. Which command identifies the package to install?

    Show the answer

    Correct answerA. dnf provides '*/libfoo.so.2'

    dnf provides searches repository metadata for the package that supplies a given file, so it finds the package even though it is not installed. The list and rpm -qa options only show installed packages, which cannot include the missing library.

    Open this question
  30. Question 130

    Services and User Management

    A build server's disk is nearly full because it holds hundreds of old tagged images that no container uses. An administrator must remove every image not used by a container, but must keep all stopped containers and named volumes. Which command does this without a confirmation prompt?

    Show the answer

    Correct answerA. docker image prune -a -f

    docker image prune -a removes all images not referenced by any container, and -f skips the prompt. Plain docker image prune -f removes only dangling images, so the old tagged images would stay. The system prune would also delete stopped containers and volumes.

    Open this question
  31. Question 131

    Services and User Management

    A Dockerfile starts FROM python:3.12-slim, then runs COPY . /app, then RUN pip install -r /app/requirements.txt. Every small source-code edit makes docker build reinstall all dependencies, which is slow. Which change to the Dockerfile fixes this?

    Show the answer

    Correct answerB. Copy only requirements.txt and run pip install before the COPY of the full source

    Each instruction creates a layer, and a changed layer invalidates every layer after it. Copying only requirements.txt first keeps the install layer cached until dependencies change. Moving the install to CMD only delays it to run time and does not speed up builds.

    Open this question
  32. Question 132

    Services and User Management

    Which files does find /var/log -type f -mtime +7 match?

    Show the answer

    Correct answerA. Files last modified at least eight full days ago

    AWhy this is right: find drops fractions of a day, so +7 needs an age of more than 7 whole days, which is 8 or more.

    BWhy not this: A file 7.5 days old counts as 7 whole days, which is not more than 7, so it does not match.

    CWhy not this: Files modified within the last seven days are what -mtime -7 matches.

    DWhy not this: Files whose age rounds down to exactly 7 days are what -mtime 7 matches.

    find -mtime counts age in whole 24-hour periods and drops any fraction, so +7 means more than 7 whole days, which is at least 8 days. A file modified 7.5 days ago counts as 7 days old and does not match.

    Open this question
  33. Question 133

    Services and User Management

    Running rmdir /var/tmp/old fails with "Directory not empty". The administrator has confirmed that the directory and everything in it are no longer needed and must remove all of it in one command without being prompted for each file. Which command does this?

    Show the answer

    Correct answerA. rm -rf /var/tmp/old

    rm -rf removes the directory and everything beneath it recursively, and -f suppresses prompts. rm -d only removes empty directories, so it fails here just as rmdir does. rmdir -p only removes empty parent directories as well.

    Open this question