Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

[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]

share|improve this question

migrated from Nov 16 '10 at 1:49

This question came from our site for professional and enthusiast programmers.

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

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à!

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

On debian I have a script (lets call it which launches X11:

su - kit -c "startx &"

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

sudo update-rc.d defaults 99 1

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

$command 1 &
$command 2 &
share|improve this answer
i should replace the last line "x-window-manager" with "exec startfluxbox" in my case? – Anonymous Apr 14 '09 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 '09 at 11:35
i found out that should live in /etc/init.d/ – Anonymous Jul 9 '10 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.

share|improve this answer

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.

share|improve this answer
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 '09 at 11:50
Then using the .profile file should work fine for you. (see first part of my answer) – Pierre-Luc Simard Apr 14 '09 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.

share|improve this answer

You must log in to answer this question.