How to modify the PATH variable?

You can modify the PATH variable using the export command in the terminal. Here are the steps to do so:

Temporarily Modify the PATH

To add a new directory to the PATH for the current terminal session, use the following command:

export PATH="$PATH:/new/directory/path"

Replace /new/directory/path with the actual path you want to add. This change will last only for the duration of the terminal session.

Permanently Modify the PATH

To make the change permanent, you need to add the export command to your shell's configuration file. Here’s how to do it for the .bashrc file:

  1. Open the .bashrc file in a text editor:

    nano ~/.bashrc
    
  2. Add the following line at the end of the file:

    export PATH="$PATH:/new/directory/path"
    
  3. Save the file and exit the editor.

  4. To apply the changes immediately, run:

    source ~/.bashrc
    

Now, the new directory will be included in the PATH every time you start a new terminal session.

0 Comments

no data
Be the first to share your comment!