Today when I logged into my server via SSH as I have been doing for the past 6 months,. However, I now receive this error message any time I run a command that makes reference to the $HOME environment variable:

-bash: cd: HOME not set

For instance, running cd throws this error, yet cd ~ correctly changes to my users home directory.

I have been searching Google and trying all of the different suggestions for hours and I'm stumped.

I have tried editing the .bashrc and .profile files to include export HOME=/home/aUser, but echo $HOME continues to return empty even after logging out and in.

As far as I know, I have not installed any software on this server in the past few weeks, but have been logging in every few days to check things.

I login to my server with a standard SSH connection string using a private and public key:

ssh -i my-server.pem [email protected]

I am still fairly new to Linux, so bear with me.

2 Answers 2


It seems ssh does not use the same init scripts when starting a session. Have you already tried editing .bash_profile?

Here is a similar question, that might give you some extra information: https://stackoverflow.com/questions/820517/bashrc-at-ssh-login


Use export HOME="/home/ubuntu" .It worked for me.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .