LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-28-2008, 08:49 PM   #1
reakinator
Member
 
Registered: Oct 2005
Location: California
Distribution: Ubuntu Feisty
Posts: 52

Rep: Reputation: 15
How to rescan bash PATH


Hi,

I have this problem where I sometimes reinstall software in /usr/local that was previously installed in /usr . After uninstalling what is in /usr, I run the command at I get something like:

r@pal:~$ pd
bash: /usr/bin/pd: No such file or directory

This is because pd is now in /usr/local/bin:

r@pal:~$ which pd
/usr/local/bin/pd

But this has not been recognized by bash, and won't be until i reboot. Is there any way to manually update this?

regards,
Rich
 
Old 05-28-2008, 09:37 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
You don't need to reboot. Just restart the X server with ctrl+alt+backspace, and log back in.

You could also try cd to your home folder and run ". .bashrc" or "source .bashrc" to reload your bash environment.
 
Old 05-28-2008, 09:44 PM   #3
reakinator
Member
 
Registered: Oct 2005
Location: California
Distribution: Ubuntu Feisty
Posts: 52

Original Poster
Rep: Reputation: 15
Ah, great. Thanks for the solution, I knew it would be some quick command.

Would you mind telling me what the 'source' command does? It doesn't appear to have a man page.

regards,
Rich
 
Old 05-28-2008, 10:08 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
source (or .) is a bash builtin. You can read about it in the bash(1) manpages.
 
Old 05-28-2008, 10:14 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
It is better to edit ~/.profile to add directories in your path. This bash script is executed when you log in. Bashrc might not be unless .profile sources it. And in that case, when opening a konsole or xterm or running a subshell the directories will be added again.

See the info bash manual. There could be a different bash startup file used instead such as .bash_login or .bash_profile. The info manual outlines the precedence. For most Linux distro's .profile is used but you can never be certain without checking.

Last edited by jschiwal; 05-28-2008 at 10:16 PM.
 
Old 05-28-2008, 10:32 PM   #6
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

It sounds like, maybe, your issue is also with the way bash is hashing recently used commands. Any shock (like a reboot) to the shell will cause it to dump (and forget that /usr/bin/somecommand is there when it's not), so all the other suggestions are excellent and valid. I just wanted to put these 2 cents in, in case it helps.

"hash -r" might be an easy way for you to just get it over with and not wait

Ex:

Quote:
-bash-3.2$ hash
hits command
1 /usr/bin/tty
2 /bin/stty
2 /usr/local/bin/mesg
-bash-3.2$ hash -r
-bash-3.2$ hash
hash: hash table empty
Hope that helps out

, Mike
 
Old 04-14-2009, 12:46 PM   #7
mlissner
Member
 
Registered: Jun 2006
Location: Berkeley, CA
Distribution: FC5
Posts: 37

Rep: Reputation: 15
Quote:
Originally Posted by eggixyz View Post

"hash -r" might be an easy way for you to just get it over with and not wait
Yes. This is the trick.
 
Old 04-14-2009, 03:35 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by jschiwal View Post
It is better to edit ~/.profile to add directories in your path. This bash script is executed when you log in. Bashrc might not be unless .profile sources it. And in that case, when opening a konsole or xterm or running a subshell the directories will be added again.

See the info bash manual. There could be a different bash startup file used instead such as .bash_login or .bash_profile. The info manual outlines the precedence. For most Linux distro's .profile is used but you can never be certain without checking.
The distro doesn't matter, and it's a bash thing only.

.profile might not be the right file either.

For interactive non-login sessions (i.e. xterm and the likes) use .bashrc, for login shells (when login in text mode, via ssh, etc) use .bash_profile, which will take precedence over any other. For global configs use /etc/profile.

More info in the "INVOCATION" section of the bash man page.

However, this is NOT a PATH issue. If /usr/local/bin wasn't in the path, no amount of reboot would help, right? So I guess that it's eggixyz who hit the nail.

About the source (or dot) command, it's a bash builtin which dumps a given shell script into the current shell, as if you typed all the commands into that file in your command line, hence, all the environment of that shell script is merged into your current shell (including whatever modifications to PATH have been done).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rescan-scsi-bus -l davimint Linux - Hardware 1 04-23-2007 07:26 PM
bash path won't stick Lokathor Debian 3 06-13-2006 12:35 PM
Rescan devices consty Linux - General 1 11-02-2005 05:13 PM
HD SCSI Rescan carma Linux - Hardware 2 03-03-2005 09:00 AM
java path in bash matador Mandriva 2 12-03-2003 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration