University of Wisconsin KnowledgeBase

Adding Directories to your Path

The purpose of this article is to show you how add directories to an environmental or system variable called PATH. If you haven't heard any of these words before, or am confused about what planet's language I'm speaking, you should double check which article you're looking for.

PATH is a variable that defines where your system looks when you want to run commands on your command prompt, terminal, or bash. From now on, I'll refer to these collectively as your system shell. Adding directories to your PATH will allow you to run executables or scripts in those directories, effectively adding commands to your system shell's dictionary of commands to recognize.

WINDOWS

1. Bring up your start menu.

2. On Windows 7, there should be a search bar in your start menu to search. On Windows 8 and 10, just go ahead and start typing. Windows should automatically recognize you are typing and a search bar should appear. In the search bar, type 'Environmental Variables'. (without quotes!)

3. It should bring a panel called System Properties. On the lower left corner of this window, there is a button labeled 'Environmental Variables...' . Click on it.

4. A new window titled 'Environmental Variables' should pop up. In the bottom half of the window, there should be a list of variables titled System Variables. These are important information entries and variables that your system keeps stored for future usage, so try not to edit them wildly. In this list, there should be a Variable called 'Path' that looks like a list of directories. Select it so that it is highlighted, and click edit.

5. A window should pop up labeled 'Edit environmental variable'. In the window should be a list of directories, and a few buttons. Click the button labeled 'New'.

6. A new entry should appear in the list with a text box inside. Type or copy paste the name of whichever directory you are trying to add. For example, if you are trying to add the Java commands for compiling, this should be directory to the Java folder in the system. Hit enter when you are done.

7. The entry should now be in the system. Double check for mistakes, and click the button labeled 'OK' at the bottom left of the window when you're done.

8. Hit OK for the rest of the windows that we opened. To double check that you added your Path successfully, open a new system shell and type in a command from the directory you just added. It should now recognize the command and run the script or executable.

LINUX/MAC

1. Open up your system shell.

2. Type the command:

echo $PATH

into the shell. Make sure you press enter so that the command executes. The output from this command is your current Path variable in the system. We'll use this later to verify the changes you've made to the Path variable.

3. In your system shell, type in the following command:

export PATH=$PATH:/type/your/directory/here

and make sure to use your specific directory in place of the dummy directory.

4. To verify that its changed,

echo $PATH

and compare it to the path variable above. If the output has changed, your changes should have been made. If not, you will want follow the steps above carefully again and see what you did wrong.