Usually Linux provides a graphical login and that works via a login manager (such as slim,xdm,gdm,kdm,etc). Also there exists an alternative that is used for console login: agetty. To enable auto login in Linux (this is an independent of display manager you might use) all you have to do is to instruct /etc/inittab to not prompt for login but instead to use an existent user and session. This can be achieved like this:
edit /etc/inittab and search for that line that looks like "c1:12345:respawn:/sbin/agetty 38400 tty1 linux"
change that line with something like "c1:12345:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty1 linux"
where auto login is either a bash script or a executable C program which you can create by your own.
Xfce auto login
#!/bin/bash
login -f <your user>
Set this script as executable chmod +x /usr/sbin/autologin autologin.c executable C program:
int main()
{
execlp( "login", "login", "-f", "<your user>", 0);
}Compile the above C program using gcc like :
gcc -march=core2 -mtune=core2 -fomit-frame-pointer -o /usr/sbin/autlogin autologin.c
strip -s /usr/sbin/autologin
Note: replace -march=core2 and -mtune=core2 above with your custom CPU code. Also, we have to make sure that
will know what session to load by default (after auto login). To achieve that all we have to do is to edit the user ~/.bash_profile file and to add the following part to the end of it:
if [ -z "$DISPLAY" ] "" [ $(tty) == /dev/tty1 ]; then
startxfce4
fi
Replace startxfce4 with your favourite session starter. Finally we have to tell Linux that we are not going to use anymore the slim/xdm/gdm/kdm display manager any more but instead the console. So let's edit the /etc/conf.d/xdm (the name depends on the display manager you are using) and change DISPLAYMANAGER="xdm" with DISPLAYMANAGER="console". Next time when your Linux will boot it will load /usr/sbin/autologin which automatically will login and then ~/.bash_profile is auto-executed, which in turn will (finally) start startxfce4 session.
Comments
1 comment
Thanks.
Leave a comment