LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   why my alias is effective only after running . /home/oracle/.bash_profile (https://www.linuxquestions.org/questions/linux-general-1/why-my-alias-is-effective-only-after-running-home-oracle-bash_profile-725775/)

redhatwannabe 05-13-2009 03:19 PM

why my alias is effective only after running . /home/oracle/.bash_profile
 
from http://ivan.kartik.sk/oracle/install...R2_redhat.html

"
echo "alias sqlplus='rlwrap sqlplus'" >> /home/oracle/.bash_profile
echo "alias adrci='rlwrap rman'" >> /home/oracle/.bash_profile
"

from http://www.oracle-base.com/articles/linux/rlwrap.php

"
Run the following commands, or better still append then to the ".bash_profile" of the oracle software owner.
".

so this is what my ~/.bash_profile looks like

Code:

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

# User specific environment and startup programs
ORACLE_BASE=/u01/app/oracle/;
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;
ORACLE_SID=tomkyte;
LD_LIBRARY_PATH=$ORACLE_HOME/lib;
PATH=$PATH:$ORACLE_HOME/bin;

alias rlsqlplus='rlwrap -i sqlplus'
alias rlrman='rlwrap -i rman'

export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH

after login in as oracle when I run
Code:

rlrman / target
bash: rlrman: command not found

it is only after running
Code:

. /home/oracle/.bash_profile
that I was able to rlrman

what should I do so that I need not run . /home/oracle/.bash_profile in order to run either rlsqlplus or rlrman?

Am I missing something? my distro is Centos 5.3

thanks a lot!

i92guboj 05-13-2009 03:25 PM

~/.bash_profile is sourced each time that you open a new interactive-login shell. So, it will not be sourced if you login using a display manager like xdm, kde or gdm and then you one a terminal emulator. For such cases, you must use ~/.bashrc instead.

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

I guess that could be the problem.

chrism01 05-14-2009 01:34 AM

A bit odd. I've got CENTOS 5.3 as well, and the default is to source .bashrc from .bash_profile anyway
Code:

cat .bash_profile
# .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

If your default shell is bash in /etc/passwd, it should run both files at login.
Maybe you didn't logout all the way after doing the changes.
It only sets them once at GUI login, then clones that for xterms.


All times are GMT -5. The time now is 02:48 PM.