Home » Questions » Computers [ Ask a new question ]

Automatic log-in in Linux

Automatic log-in in Linux

What is the easiest and most elegant way to log into a fluxbox session automatically (with no action necessary, no keypress or anything) on system startup as a certain user. [Edit 2] Not even a shell login should be necessary for the user, always the preset user should be logged in graphically. [/Edit 2]

Asked by: Guest | Views: 298
Total answers/comments: 3
Guest [Entry]

"On gentoo you have the file /etc/conf.d/local.start for this. Your
distribution probably has a similar file, where you can setup commands to be
executed at startup.

There you add this line:

su -c ""startx"" $user &

In the home directory of $user you can setup the .xinitrc to run fluxbox by adding this at the last line:

exec startfluxbox

If you need to run any more programs, prepend them in the .xinitrc. Note that the exec startfluxbox has to be run as the last."
Guest [Entry]

"From your question I deduce that you want to start a XWindow session automatically after somebody makes a login from the console.

A solution that works for any distribution is to use the .profile in the user home directory (see the bash reference manual for details). All you have to place in it are the commands that you want executed automatically by the user at login. In your case it should be something like this:

#Start the XWindow session
startx
#Exit the shell once the XWIndow session is done
exit

On a side note, you can always look at There is always GDM (often part of the gnome package), KDM (often part of a KDE package) or XDM that can start a X automatically at boot time using an rc script and then get you to your favorite Window Manager once you've logged in. GDM and KDM both offer a way to automatically login a user if that's what you are looking for. GDM, KDM and XDM are comparable to Mac OS X login window or the Microsoft Windows login window."
Guest [Entry]

"Use the /etc/inittab file.
This file spawns login shells and perhaps a display manager (like [GK]DM) when your computer enters runlevel 5 (normally).

A default login shell line make look like this:

c1:2345:respawn:/sbin/agetty -8 38400 vc/1 linux

However, with agetty, you can specify your own login program. So, replace with something like this

c1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/auto_login 38400 vc/1 linux

And then auto_login.c

#include <unistd.h>
int main() {
execlp( ""login"", ""login"", ""-f"", ""your_user_name_here"", 0);
}

Now use your shells startup script to start X like you want to."