QoTW: How do I set PATH and other environment variables?

June 6, 2011 by . 1 comments


How do I set PATH and other environment variables?

Questions about setting environment variables the PATH are very common here, and in most cases the answers are very similar to each other. In the future it would be nice to have a good Q/A for this. So the question is: How do I set the executable PATH and other environment variables on major operating systems? A good answer would include a simple explanation of what environment variables and especially PATH mean to the OS, as well as simple guidelines on how to set them accordingly.

Being an avid computer user for years now, the PATH is something that has crossed me quite a few times now. So when I saw this question, it was time to put my learning hat on.

One of the most well-known is called PATH on Windows, Linux and Mac OS X. It specifies the directories in which executable programs* are located on the machine that can be started without knowing and typing the whole path to the file on the command line. (Or in Windows, the Run dialog in the Start Menu or Windows Key+R).

So now that we know what the PATH is, where are these things set? With a quick look around, I found it was easily found on Windows 7, by simply popping open the Start Menu and typing in “Environment.” The first option was Edit environment variables for your account. Click it, and here we are:


Let’s say I wanted to add my own, for a folder I frequently visit. I shall use eclipse for example. Currently my eclipse folder is located in C:UsersSimoneclipse. I hit NEW, and add in this:


Our variable is Eclipse, and the value is where the folder is located. When i now open my start menu, I can do this:



I can also use it in command prompt to get to a folder faster:

C:>cd %eclipse%


This is just the start of what can be done with the system variables. And fear not! This is for Mac and Linux too! Just take a look at the rest of the great answers provided by our SuperUsers.

Filed under Question of the Week

One Comment

Subscribe to comments with RSS.

  • My main objection with manipulating the path via the GUI has always been that its so hard to get to that dialog. This method certainly streamlines the process. However, I think using a tool like setx. When it comes to editing the path in particular, I’ve become a huge fan of pathed, which I describe on my blog (http://www.justaprogrammer.net/2011/06/11/more-windows-command-line-path-goodness-pathed-exe/). Considering that environment variables are usually used in the context of the command line, manipulating them via the command line makes sense.

  • Comments have been closed for this post