A team deploys a shell script to start a service located in /opt/myapp/bin, but users get “command not found” when running it. Which file should be edited so that this directory is automatically included in the lookup list on login for all Bash shells?
Include export PATH=$PATH:/opt/myapp/bin in /etc/environment
Append export PATH=$PATH:/opt/myapp/bin to /etc/bash.bashrc
Add export PATH=$PATH:/opt/myapp/bin to ~/.bash_profile
Add export PATH=$PATH:/opt/myapp/bin to a new file named /etc/profile.d/myapp.sh
Putting the export line in /etc/profile.d/myapp.sh ensures that Bash reads and applies it for every user at login. Files under /etc/profile.d are sourced by the system-wide login script, making the change modular. Putting it in /etc/bash.bashrc only affects interactive non-login shells and won’t apply to login sessions. Editing /etc/environment does not support shell parameter expansion, so the existing lookup list won’t be preserved. Changes in ~/.bash_profile apply only to one user, not the entire system.
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 purpose of the PATH environment variable?
Open an interactive chat with Bash
What are the differences between /etc/profile and ~/.bash_profile?