Skip to content

Autostart X Without GDM

April 24, 2010

I’m going to explain how I auto-start ratpoison on my bare-bones Debian Stable (Lenny) system. I don’t use GDM, KDM, or any other “DM” (display manager). There are multiple steps here (involving multiple config files), but it is not complicated.

Step 1
/etc/inittab & mingetty

mingetty is an alternative to getty, which (for the sake of simplicity) I describe as the linux login program. You’ll need to install mingetty:

[bash]
#as root (i.e., using either su or sudo)
apt-get install mingetty
[/bash]

Isn’t Debian easy? We’re going to use mingetty to auto-login on tty6 (which you can access with ctrl+alt+F6). You’ll need to edit /etc/inittab:

[bash]
#First (always), make a backup copy
cp /etc/inittab ~/inittab.backup
[/bash]

[bash]
#note that I’m using “vim” here – that’s my editor of choice, but you can use whatever text editor you please (nano is easy)
#as root
vim /etc/inittab
[/bash]

Find this section:

[bash]
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
[/bash]

and change it to this:

[bash]
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6
6:23:respawn:/sbin/mingetty –autologin james –noclear tty6
[/bash]

(By the way, I should note that I usually duplicate lines I’m going to change, and then comment-out one and make my changes to the other one, so I’ll know what the line used to be. Feel free to delete the commented-out lines if you like.) Obviously you’ll also want to replace “james” with your username (unless by chance your username is also “james”).

That’s the end of step one. At this point, your computer should boot just like normal, but if you go to tty6 (again, ctrl+alt+F6), you’ll find that you’re already logged in on that tty.

Step 2
~/.profile

The ~/.profile is a script that is run after opening a login shell. There’s probably some stuff already in there that can be left alone. You’ll need to add the following IF statement, which will automatically run startx (which, appropriately, starts X) when someone logs in to tty6 (which will happen automatically, thanks to Step 1).

[bash]
#First (always), make a backup copy
cp ~/.profile ~/.profile.backup
[/bash]

[bash]
# if logging into tty6 (which will autologin), run startx
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty6 ] ; then
startx ;
fi
[/bash]

That’s the end of Step 2. Now your computer will auto-login on tty6 (thanks to /etc/inittab), and then automatically start X (thanks to ~/.profile). Now all that’s left is to start ratpoison.

Step 3
~/.xinitrc

The .xinitrc is a script that consists of commands you want to run when you start X. I have around 11 commands in my .xinitrc, but there’s only one that’s necessary to start ratpoison (which is the window manager I use — you may want to use a different WM, and if so, alter your .xinitrc accordingly). This needs to be the last command listed in your .xinitrc:

[bash]
ratpoison
[/bash]

That last step seems fairly obvious, but maybe not if this is your first time. Feel free to leave a comment if you have any questions or suggestions.

Advertisement

From → linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.