CLI Autologin and autostart a program with Ubuntu 9.10 karmik

February 12th, 2010

Warning: This post is 14 years old. Some of this information may be out of date.

My old laptop is used as a music server and so I haven't installed a desktop on it. I use MPD as my music server and ncmpd as the front-end.  However, I'm finding it a pain to enter my username, password, wait (its an old, slow lappy) and then enter ncmpd, so I looked for a way to do this automatically.  And guess what? It can be done!

This is a two step process and requires mingetty to be installed:

sudo aptitude install mingetty</pre>

Then I needed to edit /etc/init/tty1.conf and edit the getty line:

# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
#exec /sbin/getty -8 38400 tty1
exec /sbin/mingetty --autologin andrew tty1

The final step was to create a .bash_login file and add the path to ncmpc:

vim ~/.bash_login

/usr/bin/ncmpc

NOTE: I have come across a few posts that refer to /etc/event.d/tty1.conf. It seems that this has been deprecated and moved to /etc/init/tty1.conf. If your system doesn't already have one, check the other.