Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use PuTTY to connect to a remote server. I want my SSH session to start on a folder that I specify on the server, so I won't have to do cd /my/path/ every time I log in. Possible?

share|improve this question
up vote 3 down vote accepted

If you only want the behavior when you log in through PuTTY, you can use "remote command" in the PuTTY configuration dialog (under Connection/SSH). You would type

cd /my/path ; /bin/myshell

into the "remote command" field. If you have more complicated stuff to set up, you would type in the name of a script /home/yourname/yourscript for "remote command" which contains something like

cd /my/path

You need to start the shell manually in your script, otherwise the SSH session will terminate right after your script finishes.

"remote command" has the advantage that you can create different saves sessions in PuTTY where different scripts are called (if you need that).

Of course, if you always want to have the same directory (independent of PuTTY) when you log into your account, you can add the cd command to ~/.profile or ~/.bash_profile as explained by grawity.

share|improve this answer

You can add the command to ~/.profile (or ~/.bash_profile) to be automatically ran on every login.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.