LinuxQuestions.org
Help answer threads with 0 replies.
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 01-12-2005, 06:38 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
Bash Shell Messed Up I Think?


Hello all,

I think I must have run a rogue command and now when I log into my command line I get the following prompt:

-bash-2.05b$

Can any one tell me how I can fix my command prompt so that it loads my .bashrc file without me having to use the source command?

I have even tried creating a new one and I have not had any luck. Im sure there has to be a way to do this in my home directory instead of doing this in my /etc/profile file.

Any help is appreciated.

Thanks,

Lovell
 
Old 01-12-2005, 07:05 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I think you probably deleted your ~/.bash_profile. Here's a copy of mine (from a stock Red Hat 9 setup) - the stuff for your ~/.bashrc is in red (even though it should be obvious without it):

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
 
Old 01-12-2005, 07:41 PM   #3
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I don't understand, that looks the same as my .bashrc file. What is the difference and do I need them both?
 
Old 01-12-2005, 07:55 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
bash does not read in ~/.bashrc by default (unless you're executing a noninteractive shell). Open up man bash and search for the INVOCATION section to read what files are read at startup and in what order.

If you are typing commands into the shell, then that's an interactive/login shell, and that means ~/.bashrc will not be read when bash starts up. However, bash will read /etc/profile first and then ~/.bash_profile. If you want it to read ~/.bashrc, then you need to manually do so from ~/.bash_profile. If you want it to include /etc/bashrc, it's the same routine (although ~/.bashrc usually handles the whole "if [ -f /etc/bashrc ]" routine).

And just to be on the safe side, if your ~/.bashrc is sourcing itselfs (i.e. ". ~/.bashrc"), then you want to get rid of it. It's a circular reference, and I don't know how bash would handle it. At best bash would ignore it. At worst, you'll get stuck in an infinite loop.
 
Old 01-12-2005, 08:10 PM   #5
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
OK so then I need to take my edits out of my .bashrc file and put it into my .bash_profile file? That sounds like that would solve it. Sound right?
 
Old 01-12-2005, 08:15 PM   #6
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I just looked for my .bash_profile file in my home directory and your right it isn't there. Can I use the simple snipet that you posted to recreate this file?
 
Old 01-12-2005, 08:25 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Sure. There may be some things you need to add as you go. Everybody's configuration is a little different, but if you find something is missing, just add it in. The snippet I gave is good enough to start with. The last command "unset USERNAME" can probably be removed. USERNAME is probably a variable used by Red Hat's startup for some reason. I haven't taken the time to track it down yet,
 
Old 01-12-2005, 08:51 PM   #8
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
OK thanks, I will use it and reboot and hope for the best. I will post again if I am still having issues. Thanks for all the help.
 
  


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
My type is messed up in my bash rincewind Linux - General 1 06-07-2005 04:17 AM
What is Bash shell? xailer Linux - Newbie 4 11-23-2003 09:29 AM
bash shell dawood shaheen Programming 9 08-01-2003 05:07 AM
Bash Shell triplem Linux - Software 4 04-17-2003 05:11 PM
Help!!!!! Bash Shell???? DarkHorse Linux - Newbie 7 06-04-2001 12:13 PM

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

All times are GMT -5. The time now is 11:22 PM.

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