Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 need to put export PATH=$PATH:/opt/lampp/bin to my ~/.bash_profile file so that mysql from command line works on my system. Please check mysql command line not working for further details on that.

I am working on a fedora system and logged in as root user.

If I run locate .bash_profile then I get these:-


So, I modified the /root/.bash_profile file like this:-


export PATH


export PATH

But, still the change is not taking effect - Opening a new console and running mysql again says bash: mysql: command not found.

However running export PATH=$PATH:/opt/lampp/bin in console makes it work for that session. So, I am doing something wrong with the .bash_profile file. May be editing incorrect one or doing the edit incorrectly.


Before doing the above edit, I also tried by just adding export PATH=$PATH:/opt/lampp/bin at the end like this:-


export PATH


export PATH=$PATH:/opt/lampp/bin

But it didn't work. What am I missing?


share|improve this question
Does your ~/.bashrc call ~/.bash_profile? – PP. Jan 13 '11 at 9:53
how do I check that? I am basically new to server related things – Sandeepan Nath Jan 13 '11 at 9:54
Iain: those commands make .bash_profile call .bashrc, not the other way around. – MadHatter Jan 13 '11 at 10:04
@MadHatter: Thanks - miles away this morning – Iain Jan 13 '11 at 10:16
Iain: BIG GRIN! – MadHatter Jan 13 '11 at 10:32
up vote 7 down vote accepted

.bash_profile is only supposed to be run once, by the login shell. .bashrc is the file that's run for each child.

Try logging out and logging in again, then see if your .bash_profile changes are picked up.

Just for the sake of chapter and verse, this is from bash's man page:

   When bash is invoked as an interactive login shell, or as a  non-inter‐
   active  shell with the --login option, it first reads and executes com‐
   mands from the file /etc/profile, if that file exists.   After  reading
   that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
   in that order, and reads and executes commands from the first one  that
   exists  and  is  readable.  The --noprofile option may be used when the
   shell is started to inhibit this behavior.

   When a login shell exits, bash reads and  executes  commands  from  the
   file ~/.bash_logout, if it exists.

   When  an  interactive  shell that is not a login shell is started, bash
   reads and executes commands from ~/.bashrc, if that file exists.   This
   may  be inhibited by using the --norc option.  The --rcfile file option
   will force bash to read and  execute  commands  from  file  instead  of
share|improve this answer
Yes logout-login worked. Thanks – Sandeepan Nath Jan 13 '11 at 10:25

If you do not want to logout to apply the changes,

# source ~/.bash_profile

should apply your changes.

share|improve this answer

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.