Chnage direcortory upon login

Hi,

I am using Redhat 4AS and I'm planning to change the default directory (/home/psuser) upon login to /opt/directory/.

This is my .bash_profile entry:

# .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
. ~/test

This is the entry of my test file:

cd /opt/some directory/

However when i logged in using psuser account, im still directed to /home/psuser. Can anyone know what am i doing wrong?

Thanks!

Why do you have " . ~/test " I have in my test .bashrc file :

[test@host]$ cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

cd /opt/

and it works OK.

Do you mean that i should put the cd /opt/some directory/ to the .bashrc instead of the .bash_profile?

I thought that the .bash_profile is the same as the .profile of some unix machine..

It's not exactly the same. bash executes .bash_profile when you first log in, but if you are in an X session and open a new terminal window, that doesn't necessarily count as a login. Can you add some simple debug statement to your .bash_profile to see when it is actually executed?

echo '## .bash_profile' >&2

The .bash_profile is not being executed.
I'm actually doing a telnet session from a remote machine.

I also tried to add the "cd /opt/some directory" to my .bashrc but still its not wroking. I don't know what's wrong with our linux machine. :frowning:

Can you tell whether your .bashrc is being invoked when you log in then? Add some debug print there too.

The obvious question is what shell are you assigned in your password entry...

The password assigned to me is /bin/sh. Do i have to change it or do I have to use other profile?

/bin/sh doesn't use .bashrc so that kind of explains it. Try .profile instead, or chsh to change your login shell.

hi, i changed my login to bash so that I can use my .bashrc profile.. Thanks for all the help :).