A Linux administrator has placed a new set of custom scripts in the /usr/local/sbin directory and made them executable. When the administrator tries to run a script by typing only its name, the shell returns a "command not found" error. The output of echo $PATH is as follows:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Which of the following commands must the administrator run to allow the scripts in /usr/local/sbin to be executed by name for the duration of the current session?
The correct command is export PATH=$PATH:/usr/local/sbin. The PATH environment variable contains a colon-separated list of directories that the shell searches for executable files. To allow the shell to find the new scripts, their directory must be added to the PATH. The syntax $PATH:/usr/local/sbin takes the existing value of the PATH variable ($PATH) and appends the new directory, /usr/local/sbin, to the end of the list. The export command makes this new PATH variable available to any subsequent commands executed in the current session. Overwriting the PATH with export PATH="/usr/local/sbin" would remove all other essential system directories, causing most standard commands to fail. The source command is used to execute a script in the current shell, not to add a directory to the PATH. Setting permissions with chmod is a necessary step to make a script runnable, but it does not solve the issue of the shell not being able to locate the file.
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
Why does the `$PATH:/usr/local/sbin` syntax work for appending directories?
Open an interactive chat with Bash
What happens if you use `export PATH="/usr/local/sbin"` instead?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access