Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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.
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?
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,
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.