|
Home > Archive > Unix Shell > April 2005 > switching to home directory after login
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
switching to home directory after login
|
|
| tan.dalat@gmail.com 2005-04-25, 5:53 pm |
| Hello,
I have tried sudo -H -u pooh bash --login -c "cd;" and sudo -H -u pooh
bash --login, but unable to switch to the user pooh's home directory
after login. Only when I place "cd" to the end of .bash_profile (in a
development environment), I was able to accomplish that, but in reality
I do not have permissions to edit .bash_profile on production site. Is
there a way to switch to a desired directory without editing the
..bash_profile/.bashrc/.profile stuff? Thanks in advance.
| |
| Icarus Sparry 2005-04-25, 5:53 pm |
| On 2005-04-25, tan.dalat@gmail.com <tan.dalat@gmail.com> wrote:
> Hello,
>
> I have tried sudo -H -u pooh bash --login -c "cd;" and sudo -H -u pooh
> bash --login, but unable to switch to the user pooh's home directory
> after login. Only when I place "cd" to the end of .bash_profile (in a
> development environment), I was able to accomplish that, but in reality
> I do not have permissions to edit .bash_profile on production site. Is
> there a way to switch to a desired directory without editing the
> .bash_profile/.bashrc/.profile stuff? Thanks in advance.
Two ideas for you to try.
Create your own init file, and use that, e.g.
sudo -H -u pooh bash --rcfile /etc/sustartup
and in /etc/sustartup put
# First change to the users home directory
cd
# now do the standard startup
if [ -r /etc/profile ] ; then
source /etc/profile
fi
if [ -r .bash_profile ] ; then
source .bash_profile
elif [ -r .bash_login ] ; then
source .bash_login
elif [ -r .profile ] ; then
source .profile
fi
Or
sudo -H -u pooh bash -c "cd ; exec bash --login"
| |
| tan.dalat@gmail.com 2005-04-25, 5:53 pm |
| Excellent! Thanks a lot.
|
|
|
|
|