Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 would like to automatically run a program when I log on to a specific console (tty1) and no other.

I am running Ubuntu server 10.10 (no x) and I added the following line to my /etc/init/tty1.conf to automatically log me in to the first console and it works.

exec /bin/login -f USERNAME < /dev/tty1 > /dev/tty1 2>&1

I have a program (called HomeAuto) that monitors a special data acquisition board and I want it to start when this console logs in.

Is it a matter of simply adding another line to that file too?

share|improve this question

Put this in ~/.bashrc

[[ $(tty) == '/dev/tty1' ]] && /full/path/to/HomeAuto
share|improve this answer
That works, thanks. Now to add a complication, This program needs root privileges, ie. sudo /path/HomeAuto. What is the best way to automatically handle that? Can I use input file redirection to enter the password? Thanks, Mark. – Mark Jan 4 '12 at 8:46
Use sudo /full/path/to/HomeAuto and configure sudo to allow you to run the script without a password. The other option would be to call the script from /etc/rc.local – bodhi.zazen Jan 4 '12 at 16:27

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.