I'm the only frequent user on a system using gdm, but in the login screens' user list I am not moved upwards (due to most frequent use), and I cannot find a possibility to order the users manually. I confirmed they are not ordered by numeric UID. The same question has been answered here (and here another related one), but for older systems using consolekit, which has been replaced by systemd-logind and AccountsService in the meantime.

3 Answers 3


The last command lists the past successful logins on the system. This information is stored in the /var/log/wtmp file, and is used by gdm since version 3.17.2 to sort the list of users.

If you delete the /var/log/wtmp file and then reboot, the list of users will default to alphabetical order. After your next login, your user will become the most frequently used so that it will appear on the top of the list.

Note: You will lose the login history of the system if you delete the /var/log/wtmp file. You may want to create a backup of that file.

Tested in Ubuntu Desktop 20.04.3 and 21.04

  • 1
    Interesting. But why would azrdev not be listed at the top in the first place, if he already is the most frequently used? Sep 8, 2021 at 14:05
  • 3
    I think that it would be necessary to run last and see the output to check what is happening there. Perhaps another user logged in a lot of times in the past and is still on top, or perhaps the /var/log/wtmp file is locked or not updating for some reason.
    – Alejandro
    Sep 8, 2021 at 14:14

Building on Alejandro's answer, if you do not want to delete the /var/log/wtmp file, you can run a script that will "stack the deck" to ensure a specific sort order through the use of the login and expect commands.

Here's how you can do it:

  1. Open Terminal (if it's not already open)

  2. (If Required) Install expect:

    sudo apt install expect
  3. Switch to the super-user and head to /root for the sake of cleanliness:

    sudo su 
    cd ~
  4. Create a script that will login as a given account. For this example, let's call it logins.sh (but you can call it whatever you'd like):

    vi logins.sh

    Note: Feel free to use any text editor. The use of vi in this example is more the result of muscle memory than an explicit recommendation.

  5. Paste this into the new file:

    set timeout 10
    set user [lindex $argv 0]
    set password [lindex $argv 1]
    spawn login $user
    expect "Password:"
    send "$password\r"
    expect "$user@{hostname}:~$"
    send "exit\r"

    Note: Be sure to replace {hostname} with the host of your computer.

    Save the file and exit.

  6. Set the file as executable:

    chmod +x logins.sh
  7. Test it:

    ./logins.sh nozomi superSecretPassword\!123

    Note: Unless you share a name with my dog, be sure to change nozomi with the proper account name and superSecretPassword\!123 with the proper password. If your password contains characters that may be misunderstood by bash such as !, be sure to escape them with a \.

    If everything works, you will see that the specified account is logged into and, after about 8~10 seconds, it is automagically logged out.

  8. Verify this added a record to /var/log/wtmp:


    You should see something like this:

    $ last
    nozomi   pts/1                         Thu Sep  9 00:38 - 00:39  (00:00)
  9. Run the script dozens, hundreds, or thousands of times:

    for i in {1 .. 999}; do /root/logins.sh nozomi superSecretPassword\!123; done

    Note: Be sure to replace 999 with the number of times you'd like the script to run. Be aware that the number should be greater than zero and that each run will require about 10 seconds in total to complete. Also be sure to replace the username and password with the account you want to have set at the top.

  10. If there are other accounts that you would like near the top, but not at the top, run the command in #8 again, with fewer runs in the for loop. Be aware that at roughly 6 runs per minute, 1000 runs will require about 2h45m in human time to complete. You may want to run this overnight.

  11. (Optional) Consider modifying the script to run for multiple accounts and scheduling it to run daily or weekly.

This has been tested on stock Ubuntu 20.04 LTS and 21.04, but should work with every version of Ubuntu from (at least) 18.04 upwards.

  • Nice trick! Does SSH logins trigger the gdm logic, too? Because they appear in last output (i.e. /var/log/wtmp), so you could instead setup pubkey logins (~/.ssh/authorized_keys) and do the same much simpler with for i in $(seq 1000); do ssh nozomi@localhost date ; done
    – azrdev
    Sep 13, 2021 at 8:23
  • 1
    Another one @matigo: Please don't put passwords as command-line parameters, or tell people to do so: They can be read by every other local user in /proc/$PID/cmdline, and are written to your shell history too
    – azrdev
    Sep 13, 2021 at 8:25
  • Yes, SSH logins are also visible with last (along with the source IP). Your suggestion would certainly save a little bit of typing 👍🏻
    – matigo
    Sep 13, 2021 at 8:25

The reason might be, that your gdm might be configured not to include all users.

This behaviour used to be configured in /etc/gdm3/custom.conf in the [greeter] section (Include=) - this however does not seem to work anymore (see gdm disregards /etc/gdm/custom.conf exclude user list).

It might be that either user azrdev is considered a system-account by GDM3 and therefore not displayed in the user-list at all OR system-accounts are incorrectly classified as non-system accounts and therefore ending at the top of the list.

If that is the case, you can add a file named /var/lib/AccountsService/users/username and change the value of


to remove that user from the GDM greeter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .