configure the .bash_profile

Asked by Otonabee on 2006-09-12

I have two machines and have fedora and ubuntu installed individually. Why my .bash_profile is not working in ubuntu (both .bash_profiles are the same)?

.bash_profile
====================

if [ -f ~/.bashrc ]; then
     . ~/.bashrc
fi
PATH=$PATH:$HOME/bin:.
export PATH
====================

For example, I have an executable file named hello, then I can run this file by typing hello in fedora machine but not in ubuntu. I need to type ./hello in ubuntu. Anyone can tell me why and how to fix the problem?

Thanks!!!

Question information

The default .bash_profile looks like this:
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi

One way to get around your problem is to place your personal programs and commands in a directory named "bin" in you home directory.

That should work.

It is also more secure than putting the dot (.) in your search path as it is known security risk.

Make sure that your program is marked executable by doing a chmod u+x on it once you put it in the /home/your-user-name/bin directory.

I hope this helps.

Good Luck.

If these comments solved your problem, please consider updating the status of this ticket to "answered"

Thanks

Jim Jones

Ed Newton (ed-newton) said : #3

I have a similar problem, only mine is because .bash_profile doesn't get sourced when logging in through the X display manager. After logging in through X, opening a terminal window (Applications->Accessories->Terminal) and executing 'env' at the command prompt, my environment as set-up in ~/.bash_profile is not set. If, however, I use Ctrl-Alt F1 to switch to a 'non-X' terminal screen, log in, and execute env my .bash_profile is sourced and my environment is set as expected. This behavior is different from the behavior of Fedora Core 4 from which I switched to Ubuntu.

Mahmoud ElGammal (gammal) said : #4

Too many people are complaining about this behavior in Ubuntu. Please revert to the usual behavior, or if it's not possible for some reason then provide an alternative that is independent of the window manager.

Guillaume Millet (guimillet) said : #5

Have you checked in the current profile of gnome-terminal the option "Run command as a login shell" ? If this is not enabled, I think ~/.bash_profile is not loaded.

Can you help with this problem?

Provide an answer of your own, or ask Otonabee for more information if necessary.

To post a message you must log in.