XK0-005 · 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 command is installed but not found by the shell, it's typically because its directory is not included in the system's PATH environment variable.
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
(51 responses)- A71% (36)
- C2% (1)
- D4% (2)
- E16% (8)
- F8% (4)
Why each option
When a command is installed but not found by the shell, it's typically because its directory is not included in the system's PATH environment variable.
Creating a symbolic link from the executable's location (`/opt/occmd/bin/occmd`) to a directory already in the system's PATH (such as `/usr/local/bin/`) allows the shell to find and execute the command by its name directly.
Modifying the `PATH` environment variable by adding `/opt/occmd/bin` to it ensures that the shell searches this directory when looking for commands, thus allowing `occmd` to be executed by name. This change is typically made persistent by adding it to `~/.bashrc`.
Moving the application to the home directory is not a standard practice for system-wide applications, and the symlink created would only be local.
This command attempts to create a shell script but uses incorrect syntax for executing and redirecting the output of `which occmd` and would not make `occmd` executable.
`/etc/bin/` is not a standard directory for executables; `/etc` is for configuration files.
While `chmod +x` is necessary to make a file executable, and `restorecon` handles SELinux contexts, these actions do not solve the 'command not found' error if the executable's directory is not in the system's PATH.
Concept tested: Linux PATH variable and symbolic links for executables
Source: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-setting-environment-variables
Topics
Community Discussion
No community discussion yet for this question.