Linux Essentials (010-160) — Question 8
Which of the following commands adds the directory /new/dir/ to the PATH environment variable?
Answer options
- A. $PATH=/new/dir: $PATH
- B. PATH=/new/dir: PATH
- C. export PATH=/new/dir: PATH
- D. export $PATH=/new/dir: $PATH
- E. export PATH=/new/dir: $PATH
Correct answer: E
Explanation
The correct answer is E because it properly uses the export command to set the PATH variable to include /new/dir/ at the start, ensuring it is available to child processes. Option A is incorrect because it does not use the export command, while options B and C do not correctly format the variable assignment. Option D is incorrect as it attempts to export $PATH instead of PATH.