Tombuntu

Enable Automatic Login in Ubuntu 9.10 Server

Ubuntu makes it easy to enable automatic login if you’re using a login manager such as GDM. I was recently setting up a minimal Ubuntu 9.10 system with an LXDE desktop and no GDM. Here’s how I enabled automatic login.

Note: This was tested on Ubuntu 9.10. Previous versions of Ubuntu require different procedures because of changes to the way Ubuntu boots.

Open /etc/init/tty1.conf as root:

sudo nano /etc/init/tty1.conf

Change the last line of this file to (where USERNAME is the username of the user you want to log in):

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

Reboot, and the user you chose should be logged in automatically after boot. If something goes wrong, you can switch to a different TTY with CTRL+ALT+F2 and log in normally.

If you want this user to be logged into a graphical environment instead of just a shell, there’s more work to be done. Open your user’s .bashrc file:

nano ~/.bashrc

Add the following to the end of the file:

if [ $(tty) == "/dev/tty1" ]; then
startx
fi

This code will start X (the graphical environment) whenever the user logs in on TTY1. You can add more code after startx that will be executed if the user logs out of X.

Archived Comments

daybrinjer

I do $sudo crontab -e
Crontab:

@reboot startx

norbux

very good!

thanx ;)

I used to install ubuntu minimal + lxde + your tip!

Gautham

nice ….

Mimor

I can’t see why you would want this function on a server…
Or it should be locked away, very good ;)

Sarimin

I appreciate all of your information. I have found white noise helpful in my insomnia issues.

Tim

This works, but on my Xubuntu 9.10, it killed sound for my user. I could use sound as root. Normal fixes for the symptoms didn’t work, so had to undo again :( Sound came back for my user.

caic

Thank you for the tip.

If’ve tried this on Ubuntu Server 8.04 and it works. Only the configuration files change:

- tty1 file: /etc/event.d/tty1
- profile file: ~/.profile

Bob L.

I’ve tried several other things and finally:

this works on Ubuntu i386 9.10.

THANKS FOR POSTING! GREAT SOLUTION!

I.K

Thanks! I have tried to find something like this for 2h!
It works great!

swanson

Works perfectly on 10.04 as well! Could uninstall all that gdm/gnome stuff.

But; “You can add more code after startx that will be executed if the user logs out of X.” How do you implement a solution that mimicks the log out/restart x/log in again, of login manager. I don’t use it that often but it can come in handy sometimes.
“if [ $(tty) == “/dev/tty1” ]; then
startx
fi”
Should more commands go after the startx or after the fi ?

Tom2

Tom2 saying hi to Tom and thanks for the tip :^)

Respond via email