During a code-review meeting, a development team discovers that a helper script named build-report, installed at /opt/tools/build-report, cannot be invoked from arbitrary directories unless the full path is typed. The script already has execute permission and works when run as /opt/tools/build-report. The developer captures the following shell session:
$ ls -l /opt/tools/build-report
-rwxr-xr-x 1 dev dev 2076 Sep 12 14:21 /opt/tools/build-report
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
The goal is to make the utility callable simply as build-report for the current and future login sessions, without moving the file or requiring elevated privileges. Which change best accomplishes this requirement?
Set the SHELL environment variable to /opt/tools to place the directory earlier in the search order
Export /opt/tools in LD_LIBRARY_PATH so the dynamic linker locates the script automatically
Copy build-report into /usr/local/sbin, which is searched by all regular users by default
Append /opt/tools to the PATH variable in the user's login profile and reload the session
The shell searches for executables in the colon-separated directories listed in the PATH environment variable. Because /opt/tools is not present, the script is never found when its bare name is typed. Adding /opt/tools to PATH-typically by exporting it in ~/.bash_profile, ~/.zshrc, or a file under /etc/profile.d-and then reloading the environment lets the shell locate build-report automatically. LD_LIBRARY_PATH influences where the dynamic linker finds shared libraries, not where the shell finds commands. /usr/local/sbin is intended for locally installed system-administration utilities and is often excluded from a non-root user's PATH, so copying the script there would not guarantee discovery. Changing the SHELL variable merely selects a different command interpreter and does not modify the directories that interpreter searches for commands.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the PATH variable in Linux and how does it work?
Open an interactive chat with Bash
How do you permanently add a directory to the PATH variable?
Open an interactive chat with Bash
What is the difference between PATH and LD_LIBRARY_PATH?