Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

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 want an alias to SSH into another machine and then CD into a specific directory.

I try:

alias appl="ssh; cd /opt/tomcat/instances/"

It does not work. Any ideas?

share|improve this question

It doesn't work because the cd is executed on your local machine when the ssh does terminate.

Here is the way to do it:

alias appl="ssh 'cd /opt/tomcat/instances ; exec ${SHELL} -i'"
share|improve this answer

If you mean that the cd should work in the remote machine, then this cannot work.

You could change your ~/.bash_profile to do this cd for every login or just from certain machines.

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.