nerdexam
CompTIA

XK0-004 · Question #203

A systems administrator downloads an application's source files, compiles the application, and installs it per the application's installation instructions. When trying to run the application, the…

The correct answer is A. sudo ln -s /opt/occmd/bin/occmd /usr/local/bin/occmd B. echo "export PATH=$PATH:/opt/occmd/bin" >> ~/.bashrc. When a compiled binary is installed outside the system PATH, it can be made accessible by symlinking it into a PATH directory or by adding its directory to PATH. Both approaches allow the shell to locate the command without specifying its full path.

System Management

Question

A systems administrator downloads an application's source files, compiles the application, and installs it per the application's installation instructions. When trying to run the application, the system states:

$ occmd bash: occmd: command not found... Running the locate command shows it does exist in the following location:

/opt/occmd/bin/occmd Which of the following should the administrator do to allow the command to run properly? (Choose two.)

Options

  • Asudo ln -s /opt/occmd/bin/occmd /usr/local/bin/occmd
  • Becho "export PATH=$PATH:/opt/occmd/bin" >> ~/.bashrc
  • Cmv /opt/occmd ~/ && ln -s ~/occmd/bin/occmd ./occmd
  • Decho "#!/bin/bash \n ${which occmd}" > /usr/bin/occmd.sh
  • Esudo mv /opt/occmd/bin/occmd /etc/bin/
  • Fcd /opt/occmd/bin && chmod +x ./occmd && restorecon -rv *

How the community answered

(31 responses)
  • A
    74% (23)
  • D
    6% (2)
  • E
    16% (5)
  • F
    3% (1)

Why each option

When a compiled binary is installed outside the system PATH, it can be made accessible by symlinking it into a PATH directory or by adding its directory to PATH. Both approaches allow the shell to locate the command without specifying its full path.

Asudo ln -s /opt/occmd/bin/occmd /usr/local/bin/occmdCorrect

Creating a symbolic link in /usr/local/bin, which is included in the default PATH, allows the shell to find the command by name without modifying PATH itself. This is standard practice for making non-standard-location binaries accessible system-wide.

Becho "export PATH=$PATH:/opt/occmd/bin" >> ~/.bashrcCorrect

Appending 'export PATH=$PATH:/opt/occmd/bin' to ~/.bashrc adds the binary's directory to the user's PATH environment variable on each login, enabling the shell to locate and execute the command by name.

Cmv /opt/occmd ~/ && ln -s ~/occmd/bin/occmd ./occmd

Moving the application to the home directory and creating a relative symlink does not place the binary in a PATH-accessible location and would also break the relative symlink context.

Decho "#!/bin/bash \n ${which occmd}" > /usr/bin/occmd.sh

This command uses invalid shell syntax with unescaped braces and misuses 'which', and writing a wrapper to /usr/bin would not resolve the underlying PATH issue correctly.

Esudo mv /opt/occmd/bin/occmd /etc/bin/

/etc/bin/ is not a valid or standard directory on Linux systems, so moving the binary there would not make it accessible via PATH.

Fcd /opt/occmd/bin && chmod +x ./occmd && restorecon -rv *

chmod +x makes the file executable and restorecon restores SELinux file contexts, but neither action places the binary in a PATH-accessible location or resolves the 'command not found' error.

Concept tested: Making compiled binaries accessible via PATH or symlinks

Source: https://www.gnu.org/software/bash/manual/bash.html#index-PATH

Topics

#PATH variable#symlink#shell configuration#binary path

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice