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:
Open the
.bashrcfile in a text editor:nano ~/.bashrcAdd the following line at the end of the file:
export PATH="$PATH:/new/directory/path"Save the file and exit the editor.
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.
