Friday, March 27, 2009

linux: automatic login

The time of laptop-per-human is almost came. Laptop is something personal like toothbrush - you are the only owner.
I do not really worry who is using laptop - because only I use it. So logging in each time I plug power on seemed strange for me. So I've forced gdm(gnome desktop manager) to autologin mode. The time passed and I realized that the only purpose of gdm is to automatically login to my session. "What the hell?" I said to myself. Why do I have to spend my laptop's resource on something that I don't really need(yep, I prefer to spend memory and cpu on emacs and gcc)?

So I've found nice approach to autologin to X session w/o any desktop managers.
That's really simple.
You should edit /etc/inittab configuration file and replace line which loads desktop manager with command that will launch X session for your user. For me it is

x:5:once:/bin/su <user> -l -c "/bin/bash --login -c 'ck-launch-session startx' &>/dev/null"

For distributions that use another approach to run DM(like gentoo - they load DM as a startup script) you can replace the line which loads DM with
/bin/su <user> -l -c "/bin/bash --login -c 'ck-launch-session startx' &>/dev/null"
or disable loading the startup script and modify inittab like I showed above.

Also it's possible to make automatic login in virtual consoles:
c1:2345:respawn:/sbin/mingetty -n -l <user> vc/1 linux
or
c1:2345:respawn:/sbin/agetty -n -l <external program> 38400 vc/1 linux
Whe external program will perform login for you. The program might be quite simple - just exec 'login' for your user.

No comments: