$PATH

To set the PATH for a specific tool, you can follow these steps:

  1. Identify the tool's directory: Determine the directory where the tool's executable file is located. For example, let's assume the tool is located in /path/to/tool_directory.

  2. Temporarily set the PATH: Open a terminal and use the following command to temporarily set the PATH for the current shell session:

    export PATH="/path/to/tool_directory:$PATH"

    This command adds /path/to/tool_directory to the beginning of the PATH variable, ensuring that the shell looks for the tool's executable file in that directory first. Note that the existing value of PATH ($PATH) is appended after the new directory, separated by a colon (:).

    With this temporary setting, you can use the tool from the command line within the current session.

  3. Permanent PATH setting:

    • For a single user: If you want to set the PATH permanently for a specific user, you can add the export command to the user's shell startup file (~/.bashrc, ~/.bash_profile, or ~/.profile). Open the desired file using a text editor and add a line like this:

      export PATH="/path/to/tool_directory:$PATH"

      Save the file and either open a new shell session or run the source command to apply the changes to the current session:

      source ~/.bashrc

      Replace ~/.bashrc with the appropriate shell startup file for your shell.

    • For all users: If you want to set the PATH system-wide for all users, you can modify the /etc/environment file. Open the file as root using a text editor and modify the line that starts with "PATH=". Make sure to include the /path/to/tool_directory along with the existing PATH directories, separating them with a colon (:). For example:

      PATH="/path/to/tool_directory:$PATH"

      Save the file. The next time the system starts or a new shell session is opened, the modified PATH variable will take effect for all users.

With the PATH set appropriately, you should be able to run the tool from any location in the command line without specifying its full path.

Last updated