Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to change the $PATH using the following command:

export PATH=/opt/subversion/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin

(i use the full variable because concatenating duplicated stuff or something)

However, on another terminal

echo $PATH
doesn't show the change (i've added the /opt/subversion/bin). I read here: that I should run
. ./.profile

But I get

-bash: ‘export: command not found

error on this command (I was on the home directory, after running 'cd').

Tried also to log off and on, no trace for the subversion I added to the path.

Have I missed something? Thanks.

share|improve this question
up vote 0 down vote accepted

Seems like something is wrong with the .profile file, there should be any sort of single quote before the export (See bash your error). I can't think of how that got there right now, but check the file for any strange character with cat -vE ~/.profile (Which hopefully works in OS X).

share|improve this answer
Thanks -- I ran $ cat -ve ~/.profile (with lowercase e, cause it threw an illegal option error), then got - ?M-^@M-^Xexport PATH=/usr/local/mysql/bin:M-^@M-^Y$ export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"$ – elado Oct 29 '09 at 12:41
Having trouble parsing that .. :-), I don't what ^X is, are you editing this with some sort of unicode or funny gui editor? I might try recreating the file with some sort of emacs/vi editor. I think it might be hidden characters that are making this not work... – Kyle Brandt Oct 29 '09 at 12:56 - here are the commands. I've never edited this file before, only thru the terminal with 'export' command. I've just ran 'vi ~/.profile' and deleted the strange chars and saved. Now I've lost the vi command :| (the vim still opened). The . ./.profile now doesn't throw error. The echo $PATH shows: /usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/mysql/bin: Tried to edit the .profile again and adding the export command with the full variable and save, then ran . ./profile but $PATH still not full, and vi doesn't work. Thanks... – elado Oct 29 '09 at 13:51
1) No vi command (Probably because whereever it is, is no longer in your PATH). 2) 'Tried to edit the .profile again and adding the export command with the full variable and save,' Sorry, I am not quite sure what you mean with that, but whatever the original path is set to is porbably set in /etc/profile or /etc/bash.rc or something like that. So you can look at that file to see what orginally was. – Kyle Brandt Oct 29 '09 at 15:10
YES!! I've opened .profile in a text editor and edited the path manually - I've run the . ~/.profile and it worked! Thanks. – elado Oct 29 '09 at 16:15

A few things:

  • Are you setting $PATH on the cmdline in terminal 1? If so, even with the export, terminal 2 won't see it. I assume this isn't the case because you mention .profile later, but it' wasn't completely clear to me.

  • After editing your ~/.profile (that's the .profile file in your home directory), doing

    . ~/.profile

Should source that file into the current environment.

  • Finally, I'm always nervous about setting path in a user file without building on the existing value of $PATH. You're forced to keep up with changes in the system-wide settings. So, I recommend you do something like:

    export PATH=$PATH:/path/to/perforce:/path/to/subversion:/path/to/git

You can put $PATH before or after your additions depending on what you want searched first.

If you've done as I've said with ~/.profile, please post the ~/.profile file for us and we'll go from there.

share|improve this answer
The value I've put in PATH was its exact value before the change so it's not "hard coding". As I mentioned - running . ~/.profile (or . ./.profile) threw an error (see Kyle's answer's comments). Thanks for the answer! – elado Oct 29 '09 at 13:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.