Shell Person Help me keep the shell people alive.

24Apr/105

Autostart X Without GDM

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:

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

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:

#First (always), make a backup copy
cp /etc/inittab ~/inittab.backup
#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

Find this section:

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

and change it to this:

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

(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).

#First (always), make a backup copy
cp ~/.profile ~/.profile.backup
# if logging into tty6 (which will autologin), run startx
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty6 ] ; then
    startx ;
fi

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:

ratpoison

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.

Comments (5) Trackbacks (1)
  1. Thanks :) It works fine.

  2. thanks for the howto..although somehow this doesnt work for me…when i start up my box (just setting it up with debian 6.06 netinst) i have to switch manually to tty6 where im logged in automatically but the script doesnt start the x server…uname says i am using the 2.6.32-5-686 i686 kernel…ill go to sleep now and try to figure it out tommorrow…good night and take care :-)

  3. Nice work, looking exactly same :-)

  4. Drives me crazy when people post “solutions” to problems…then don’t read or react to comments for 3 years!


Leave a comment