Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have some Amazon EC2 instances that run Ubuntu 10.04.1 LTS.

Every time I connect to those instances I run a couple of simple commands, like a cd <repository>, a git status etc.

How can I add them to a script / to which script should I add them so they would be automatically ran every time, on SSH connect?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

The solution is basically to run a script on login.

Since Bash looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

I did a simple ls -la ~, saw that from that hierarchy .profile was the first only one available, so I just appended my commands here.

Problem solved!

share|improve this answer
add comment

You can add all your commands in a single script and can call the script through the SSH line.

For eg. I will dump all the commands in /home/vidyadhar/commands.sh At the time of ssh i will do it as follows ssh vidyadhar@machine `/home/vidyadhar/commands.sh'

share|improve this answer
add comment

Your Answer

 
discard

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.