I've been playing with Ubuntu Oneiric on my netbook (where breakage isn't really a concern); I like the new lightdm login screen, but it has one minor annoyance: in addition to my own user account, there's another account for occasional use by my girlfriend, and her user account is the one that's always focused (presumably because it's first alphabetically).

I know how to fix this in gdm but haven't found a solution for lightdm. Does anyone know how to set it up so my account is highlighted by default?


In /etc/lightdm/lightdm.conf

Go down the file until you get to:

# greeter-hide-users=false

Un-comment it, make sure the value is false.

  • 2
    I had been under the impression that the commented out options and values in /etc/lightdm/lightdm.conf indicated the default values but that is not the case. So simply un-commenting lines can have an effect. Also some options seem to take effect on logout/login, this option however seems to required a reboot to take effect.
    – PiersyP
    Oct 30 '16 at 17:03
  • 1
    There are three levels for this, with the config files being read in this order (i.e. last overrides previous): files in /usr/share/lightdm/lightdm.conf.d, files in /etc/lightdm.conf.d and /etc/lightdm.conf itself. The defaults might be overridden earlier and need to be reset later then.
    – FelixJN
    Apr 1 '19 at 19:32

hackerb9's answer did it for me, but rather than creating a script, it's much simpler to simply "freeze" the config file. Here's what to do:

  • Open the config file for editing (note that depending on the flavor of Ubuntu you're using, the folder inside .cache might be called something else)
    sudo nano /var/lib/lightdm/.cache/lightdm-gtk-greeter/state
  • Edit the following line to reflect the default user's account name
  • Perhaps it would be good to also add a comment to the file stating that it is locked and how
  • Run the following command to "freeze" the file so it can't be changed by lightdm
    sudo chattr +i /var/lib/lightdm/.cache/lightdm-gtk-greeter/state

Now lightdm won't be able to update this file when a different user logs in ensuring that your default user will always be listed when the login screen loads.

If this works for you, and you decide to up-vote, please up-vote hackerb9's post as well as this is a derived by separate method.

  • 1
    Very nice, @b_laoshi. I like that you don't depend on a shell script. I do suggest putting a comment in the state file so future sysadmins (or yourself) will know why it's immutable. I think this is a fine solution on a single machine, but I should mention there might be downsides for people trying it in an lab situation. (1) extended filesystem attributes shouldn't be relied on to persist on a backup. (2) likewise, if you have a lab of computers that are copied from a network master, fs attributes can be lost. (3) /var/lib is not guaranteed to be preserved, e.g., on an upgrade.
    – hackerb9
    Jul 14 '17 at 9:34

The "default-user" option has been removed from lightdm. Why? Nobody knows. It's been five years since this question was originally asked and it's still broken. Lightdm now saves the state of who last logged in in a hidden file here:


So, here's a three step workaround:

  1. Create a shell script called /usr/local/bin/lightdm-default-user with the following contents:

    # LightDM removed the default-user option.
    # The only recourse now is an ugly kludge. 
    # Note that if you want to default to the "Guest Session",
    # you need to specify the last user as "*guest".
    /bin/echo -e '[greeter]\nlast-user=*guest' > /var/lib/lightdm/.cache/lightdm-gtk-greeter/state
  2. Make it executable: chmod 755 /usr/local/bin/lightdm-default-user

  3. Have lightdm automatically run the script upon start up by editing /etc/lightdm/lightdm.conf and adding a line in the [SeatDefaults] section:


This is horrifically ugly but it is, unfortunately, the best solution at the moment.

  • I suspect it was done for security reasons (i.e., username is considered sensitive information). Jun 13 '17 at 19:09
  • This was exactly what I needed. I took a slightly different approach though. The shell script is not actually necessary. See my answer for an explanation of "freezing" the state file.
    – b_laoshi
    Jul 8 '17 at 6:42

Edit the file /etc/lightdm/lightdm.conf (gksu gedit /etc/lightdm/lightdm.conf) and add a line like this at it:

  • Thanks, but so far I've had no luck - has this worked for you? I've tried different variations, eg default-user=sean (my login name), default-user=1000 (my UID), etc but so far, no change. Aug 31 '11 at 21:20
  • I've read it somewhere, don't remember where. I'm not using lightdm yet. I will research more.
    – desgua
    Aug 31 '11 at 21:39
  • OK, this seems to work now - with the latest updates the correct user is selected by default. Not sure if this is due to me adding the default-user line, or if it now remembers the last login. (I guess I could try removing the default-user line and see what happens - but at least it works now!) Oct 1 '11 at 17:07
  • 2
    As a quick note to anyone who's reading this and using 12.04, this setting no longer has any effect and is not in the example conf file anymore. I believe that as of 12.04 the default will be the last logged-in user.
    – mfisch
    Oct 2 '12 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.