What command adds the directory /new/dir/ to the PATH environment variable?

Prepare for the LPI Linux Essentials 010-160 Test. Study with flashcards and multiple choice questions, each question offers hints and explanations. Get ready to ace your exam!

To correctly add the directory /new/dir/ to the PATH environment variable, the command must achieve a couple of things: it needs to append the new directory to the existing directories in PATH, and it needs to properly export the updated variable so that it is recognized in the current shell session and by any child processes.

The command that performs all these actions correctly is export PATH=/new/dir:$PATH. This command assigns to PATH the value of /new/dir followed by the existing value of PATH, ensuring that the new directory is prioritized. The use of the export command makes the updated PATH variable available to other commands and processes initiated from the current shell, which is critical for using newly added directories in command lookups.

The prefix /new/dir: ensures that if there are executables in /new/dir/, they are found before any executables in the existing paths. This order can be important for executing scripts or programs that may exist in multiple directories.

In comparison, some other options do not properly achieve either the correct assignment of the PATH variable or the export process necessary for shell usage.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy