How to add new path in environment variable
To add a new path to an environment variable, you can follow these steps:
Windows:
- Right-click on "Computer" or "This PC" and select "Properties".
- Click on "Advanced system settings" on the left side.
- Click on "Environment Variables".
- Under "System Variables", scroll down and find the variable you want to add the path to (e.g.
PATH
). - Click "Edit" and then "New".
- Enter the new path and click "OK".
- Click "OK" again to close the "Environment Variables" window.
macOS (using Terminal):
- Open Terminal.
- Run the command
export PATH=$PATH:/new/path
(replace/new/path
with the actual path you want to add). - To make the change permanent, add the following line to your shell configuration file (e.g.
~/.bashrc
or~/.zshrc
):export PATH=$PATH:/new/path
- Reload your shell configuration file by running
source ~/.bashrc
orsource ~/.zshrc
.
Linux (using Terminal):
- Open Terminal.
- Run the command
export PATH=$PATH:/new/path
(replace/new/path
with the actual path you want to add). - To make the change permanent, add the following line to your shell configuration file (e.g.
~/.bashrc
or~/.zshrc
):export PATH=$PATH:/new/path
- Reload your shell configuration file by running
source ~/.bashrc
orsource ~/.zshrc
.
Additional tips:
- Make sure to use the correct syntax for the path (e.g.
/usr/local/bin
instead ofC:\usr\local\bin
). - If you're adding a path to the
PATH
environment variable, make sure to separate multiple paths with a colon (:
) instead of a semicolon (;
). - If you're using a shell other than Bash or Zsh, the syntax may be different. Consult your shell's documentation for more information.
After adding the new path, you should be able to access the files and executables located at that path from your terminal or command prompt.