HOWTO: Add a Directory to my Path Statement/Variable.

September 29, 2005 by Jon  
Filed under How To

When you type the name of an executable file, GNU/Linux searches for that executable in all the directories specified in the PATH environment variable.

By default, your GNU/Linux distribution probably set up a default PATH variable during install. To see what your current PATH variable is set to, in a terminal window, type:

echo $PATH

and press ENTER. The system should respond by writing out the current value of the PATH variable. That probably looks something like:


To add a directory to the PATH statement is a relatively straight forward process, but first a question needs to be answered:

Note that these instructions are for a bash shell which is very common n GNU/Linux systems. If you are running another shell, please consult the directions for that shell.

Which users do you want to be affected by this new PATH value?

  1. In a home GNU/Linux system, it’s likely that there is only one user and therefore the answer is: me and my root account.
  2. If you are running a multi-user system, then the answer is likely: everybody and root.
  3. Possibly the third answer is: only ‘joe’ or some other single user on the system.

Regardless of which user(s) are to affected, the same line(s) need to be added to a profile file. The only variable is: which file?

The line(s) or code to add are:

PATH=$PATH:/new/path (where /new/path is the directory you want to add)
export PATH

NOTE: The export command need only be called once in the profile file and after all the PATH statements in that file. If an export command is already present in the applicable profile file (see below), then you need not add another one.

You are going to add these lines to the following location depending on which user(s) you want to affect:

  1. To add that PATH to every user but root, add the line(s) to /etc/profile
  2. To add that PATH to root, add those line(s) to /root/.bash_profile
  3. To add that PATH to a specific user(s), add the line(s) to /home/user/.bash_profile
Share and Enjoy:
  • StumbleUpon
  • Digg
  • Facebook
  • Mixx
  • Google
  • TwitThis
  • Reddit
  • Yahoo! Buzz
  • Slashdot


4 Responses to “HOWTO: Add a Directory to my Path Statement/Variable.”
  1. Alex says:

    Thank You

  2. conan says:

    I am brand new to linux (using Ubuntu 6.06) and am about to go nuts and give up on linux. All help advice I find online uses computer speak that I can’t hope to comprehend.

    SO … please, if I do not have permission to modify the profile files mentioned above, what do I do? I am trying to gain access to my NTFS drives by installing NTFS-3g, but I can’t do that bc the Synaptic package manager doesn’t have it, and the GCC compiler isn’t in my $PATH, and apparently I can’t modify that $PATH.

    Though I’m not convinced that would help me anyway, as I also can’t install the latest Firefox, which doesn’t require a compiler and yet I have zero clue (and cannot find any help files) how to install a program already in binary. So if you could help me with that too, it would be fantastic. Please please please … I’m begging.

  3. Bill says:


  4. balakumar says:

    Thanku so much for very nice artcles

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

About Us | Advertise with us | Blog for EveryJoe | Privacy Policy | Terms of Use
Get This Theme

All content is Copyright © 2005-2009 b5media. All rights reserved.