I have two PuTTy sessions open to the same host. One one cd ~ gets me back to my home dir fine and on another one it doesn't -- stays in the same dir.

I have never seen something like this happen.

Any idea why this might be happening?

OS: SunOS 5.10

  • what shell are you using? Also, dump both environments, ie set > env_goodwindow ; set > env_badwindow` and diff them. Same for stty settings. Good luck.
    – shellter
    Commented Oct 5, 2012 at 19:15
  • BTW, cd alone takes you to your home directory. No need for the ~ Commented Oct 5, 2012 at 20:24
  • 1
    cd alone doesn't work either ... :(
    – amphibient
    Commented Oct 5, 2012 at 20:51
  • Does this always happen each time you open two ssh connections to the host, or did it happen just once?
    – user13764
    Commented Oct 6, 2012 at 1:38

1 Answer 1


It sounds like you've changed or unset your $HOME environment variable in one of the ssh sessions.

$HOME is the default arg for the cd built-in, at least for all the sh-like shells that I have installed on my system (incl. dash, bash, ksh, and zsh).

They all have something like this in their man page (from dash):

 HOME   The home directory of the current user; the default argument for
        the cd builtin command.  The value of this variable is also used
        when performing tilde expansion.
  • csh and tcsh use $home (lowercase).
    – cas
    Commented Oct 6, 2012 at 3:19

You must log in to answer this question.

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