Shell Script bashrc

Status
Not open for further replies.

ZeroShade

In Runtime
Messages
498
I've included in the bashrc file a check to see if root is logged in and change current directory to "/". But now the other others go to "/" as well... any ideas?

# Change directory to root if not already there.
if [ "$(whoami)" = "root" ]; then
cd /
fi
 
I have root and then the user. When I log in as root I want the directory to be changed to "/". Which it does... but it also causes the user to do the same thing?
When I log in as the user it prints this now and changes to "/" as well. Its default is to the users home directory which makes sense. But I can't find anything in the bashrc file that relates to that which happens before my script. I simply want the root to start at / and the users to start at their home directory. Any thoughts?

Could not chdir to home directory /home/user: No such file or directory
 
Code:
sudo echo "cd /" >> /root/.bashrc
That should do the trick. I'm assuming your root's home directory is in the same place as mine.
 
Status
Not open for further replies.
Back
Top Bottom