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]

There are some setups where this is nice.

(Please put remarks about whether this should be discussed at all or better kept secret to the other question: https://stackoverflow.com/questions/747008/is-it-good-to-make)

[EDIT 1]

How could I lock fluxbox immedeately then (using xtrlock) but at the same keep starting my favourite applications.

The result would be: I switch on the box, go and have breakfast, when I come back I unlock the box with my password (accepted by xtrlock) and everything is in place.

Is it impossible or how could it be done to break this scheme in "edit 1", imagine someone presses ctrl-c at the right time when fluxbox is coming up or whatever is possible. Or that person could use the mouse to klick somewhere in an application that start before xtrlock prevents it.

(I am aware of the fact that someone might see the contents of the screen but that would be ok for me.)

[/EDIT 1]

  • it was closed because it is not programming related (ie. should be on server fault, not stack overflow)
    – Jiaaro
    Jul 21, 2009 at 13:29
  • sorry people (of stackoverflow), you either move the question or leave it open or find soemthing healthy.
    – Anonymous
    Aug 1, 2009 at 11:05
  • 1
    Shouldn't this question be moved to Super User, not just left closed? Nov 15, 2010 at 23:06
  • which distribution?
    – warren
    Nov 16, 2010 at 2:38

7 Answers 7


I suppose you use GDM login manager. In its configuration file /etc/gdm/gdm.conf enable autologin feature:


You can also define a timeout for automatic logins. Restart gdm and voilà!

  • I checked the content of the threadstarter but could not find GDM being mentioned. I would thus assume that he may have asked for a generic way, so that might also include non-GDM specific variants.
    – shevy
    Dec 23, 2019 at 7:32

You can also use rungetty. It is designed specifically as a getty replacement that 'runs' something. So, you can set it to startx, run fluxbox and what nots.


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.


On debian I have a script (lets call it autologin.sh) which launches X11:

su - kit -c "startx &"

Which is in turn installed via update-rc.d:

sudo update-rc.d autologin.sh defaults 99 1

I also disable all login managers like {k,g,x}dm. Then in ~/.xinitrc I would have:

$command 1 &
$command 2 &
  • i should replace the last line "x-window-manager" with "exec startfluxbox" in my case?
    – Anonymous
    Apr 14, 2009 at 11:16
  • x-window-manager is maintained by the system to point to the window manager of your choice. Follow the symlinks to see this. You can change it, though I don't: that way when I install a new WM, I don't need to change the script :) This will also allow any WM-specific startup scripts to run.
    – freespace
    Apr 14, 2009 at 11:35
  • i found out that autologin.sh should live in /etc/init.d/
    – Anonymous
    Jul 9, 2010 at 17:11

Ok, there's numerous answers for the automatic login - it's a feature of kdm & gdm, or can be done by starting x explicitly rather than using a display manager, etc.

As for the locking part, there's a file you can play with:


At the start of the file add in the following lines:

/usr/bin/xtrlock &
/usr/bin/sleep 5

xtrlock, does what you want with the session locking. The ampersand means do it in the background - carry straight on with the next command, the sleep helps to ensure that the screen is locked before any other applications are started.

Notice that the last line of this startup file is the line that actually runs fluxbox, so this runs way before any applications start up.

In terms of security, I don't think you can press ctrl-c to get around it, but security is obviously less tight than in the full login scenario.


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
#Exit the shell once the XWIndow session is done

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.

  • sorry for my unclear question. no, I am looking for a totally auto loging without typing a username or password or even touching a key. sorry for my bad english.
    – Anonymous
    Apr 14, 2009 at 11:50
  • Then using the .profile file should work fine for you. (see first part of my answer) Apr 14, 2009 at 12:37

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.