Ubuntu and Autologin to load OpenBox, XFCE, Others

Hello all,

I am working to rebuild one of my servers and thought I would share a tidbit of information. I decided to rebuild the server using as little as possibly needed, so I opted to use the Ubuntu 7.10 Gutsy Server install. This does not have any kind of desktop applications or X windows installed.

Below is information I found online for how to automatically have the server login and start an X session from the TTY1 default connection. This will then allow you to VNC into the server after the server boots up.

First note, to look at  this website to install the needed pre-requisites for a minimal system. Here you can choose which Window Manager to install as well. After you are done installing the window manager, continuing reading on below.

OK, now that you have that installed, note that this again was tested and works just fine on an Ubuntu 7.10 Gusty install. The guides that I found were for other versions, but they needed to be tweaked just a bit to work with 7.10.

follow these commands just after logging into the console:

sudo apt-get install gcc-3.4 build-essential
nano autologin.c

Inside the autologin.c file, this is the code that is entered; substitute USERNAME with your login username.

int main() { execlp( “login”, “login”, “-f”, “USERNAME”, 0); }

Continuing on at the command line:

gcc-3.4 -o autologin autologin.c
sudo cp autologin /usr/local/sbin
sudo nano /etc/event.d/tty1

In the tty1 file, go to the ‘respawn’ line and type this exactly in. ‘respawn’ needs to be on a line by itself and then type the line below it. Note that you should be a # in front of the current respawn.

exec /sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1

That is all! You should be able to reboot your PC and it automatically login with the username you specified and start the Window Manager.

It is then safe to remove gcc-3.4 and build-essential if you had to install it for this purpose only.

sudo apt-get autoremove gcc-3.4 build-essential

Leave a Comment