Cover Image for How to set path?
190 views

How to set path?

The Setting the PATH environment variable is necessary when working with command-line tools or running programs that are not in the system’s default search path. It allows you to execute these tools or programs from any directory in the command prompt without specifying the full path to the executable. Here’s how to set the “PATH” environment variable in different operating systems:

Windows:

  1. Open the “Start” menu and search for “Environment Variables.”
  2. Click on “Edit the system environment variables.”
  3. In the “System Properties” window, click the “Environment Variables” button.
  4. In the “Environment Variables” window, under the “System variables” section, scroll down to find “Path.”
  5. Select “Path” and click the “Edit” button.
  6. In the “Edit Environment Variable” window, click “New” and add the path to the directory containing the executable or script you want to add to the PATH. For example, if you want to add “C:\MyFolder” to the PATH, add that directory.
  7. Click “OK” to save the changes.

Linux and macOS (Unix-like systems):

  1. Open a terminal window.
  2. Edit your shell’s profile file, such as .bashrc, .bash_profile, .zshrc, or .profile, depending on your shell. You can do this using a text editor like nano, vim, or gedit.
  • For example, to edit the .bashrc file, you can use the command: nano ~/.bashrc.
  1. Add the following line to the profile file, replacing /path/to/directory with the actual directory you want to add to the PATH:
   export PATH=$PATH:/path/to/directory
  1. Save the profile file and exit the text editor.
  2. To apply the changes, you can either:
  • Close and reopen the terminal window.
  • Run source ~/.bashrc (or the appropriate profile file) to reload the configuration.

After setting the PATH, you should be able to run the executables or scripts in the specified directory without specifying the full path. For example, if you added “/path/to/directory” to the PATH, you can run a script in that directory by simply typing its name in the terminal.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS