Is it possible to unlock the 13.04 Gnome shell login screen from a command line? A user is logged in to Gnome shell, I can log in to a console as this user. I also have root access.

This is for accessing an active X11 display through VNC, without having to enter the password.


gnome-screensaver-command -d

as suggested in a blog post didn't help.

login screen

  • Is ssh throwing you any output or error?
    – Braiam
    Commented Sep 3, 2013 at 21:46
  • @Braiam: I can ssh in, that's not the problem. It's for accessing an active X11 display through VNC, but without having to enter the password.
    – krlmlr
    Commented Sep 3, 2013 at 22:37

5 Answers 5


I'm assuming you have a recent linux system with systemd (e.g. Ubuntu 16.04 or newer).

If you need to unlock your own session, just run loginctl unlock-session (no root required because it's your own session). If you have multiple sessions and want to select just one, run loginctl list-sessions to identify session and then run e.g. loginctl unlock-session c187.

If you need to unlock all sessions, just run sudo loginctl unlock-sessions (note plural form). Note that this will immediately unlock ALL sessions no matter which user is running the screen saver.

If you need more information to identify the correct session, you can try something like this:

loginctl list-sessions --no-legend | while read id rest; do echo; loginctl show-session $id; done
  • 3
    This is the only answer that works on 16.04 Commented Jun 15, 2017 at 12:20
  • 1
    You need sudo if you want to unlock screen savers of ALL sessions (including sessions not running with your user id). Commented Jun 20, 2017 at 15:57
  • 2
    Also note the last s in unlock-sessions. If you want to unlock only your own session, just do loginctl unlock-session. Commented Jun 20, 2017 at 16:04
  • 2
    It should be the accepted answer!
    – bric3
    Commented Jul 21, 2018 at 13:19
  • 1
    It still works on 22.04
    – Oliver R.
    Commented Aug 18, 2022 at 6:40

The problem with executing commands like gnome-screensaver-command from an SSH session is usually that they don't automatically connect to the appropriate session bus for the active desktop session - usually, setting the DISPLAY variable will fix that, for example these work for me (logged in via SSH as the same user who owns the locked X session, which is on DISPLAY :0):

$ DISPLAY=:0 gnome-screensaver-command -d

to unlock, and

$ DISPLAY=:0 gnome-screensaver-command -l

to lock.

Alternatively, you can toggle the active state using dbus-send - for example

$ export DISPLAY=:0
$ dbus-send --session \
          --dest=org.gnome.ScreenSaver \
          --type=method_call \
          --print-reply \
          --reply-timeout=20000 \
          /org/gnome/ScreenSaver \
          org.gnome.ScreenSaver.SetActive \

Source: https://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html#gs-examples

  • 1
    Unfortunately, neither of these methods unlocked the particular screen lock installed on my system (see screenshot). How can I find which process is responsible for locking the screen anyway?
    – krlmlr
    Commented Sep 5, 2013 at 19:22
  • 1
    Do the commands return an error? If so please post it. To see if a different screensaver is running you could try ps -fu <username> | grep saver - it is possible that xscreensaver is being used instead of gnome-screensaver, in which case you could try DISPLAY=:0 xscreensaver-command -deactivate. Commented Sep 5, 2013 at 20:31
  • 1
    I tested this answer on Ubuntu 14.04. It doesn't work. It unblanks the screen, but the screen remains locked.
    – kasperd
    Commented Jun 10, 2015 at 21:23
  • gnome-screensaver is not present on Ubuntu 22.04 it seems. gsd-screensaver might be the replacement. Commented Jan 13, 2023 at 18:39

The following worked for me:

sudo killall gnome-screensaver

Especially helpful when you're logged in via SSH with another user.

  • Confirmed, I had this problem when keyboard wasn't typing on the unlock screen, but was able to switch to terminal using CTRL+ALT+F3 and this screensaver killer helped. Then I just went CTRL+ALT+F2 back to the session that was locked :)
    – jave.web
    Commented Oct 3, 2018 at 5:53
  • This works when X2Go is showing the lock screen and not responding :)
    – endolith
    Commented Feb 20, 2019 at 6:57

I had a problem with gnome 3's screen lock (screensaver) being stuck at a blank screen. I managed to work around it by replacing the gnome-shell window manager.

Ctrl+Alt+F1 and log in on a virtual console, then:

pkill -QUIT gnome-shell
DISPLAY=:0.0 gnome-shell -r &

(& Backgrounds the new gnome-shell so you can log out of the virtual console and keep it running. Alternatively use Ctrl+Z to suspend the gnome-shell process, and bg to background it.)

It might not be elegant, but it finally allowed me to get back to my desktop apps without having gnome force me to logout.

  • Thanks, I'll try and see if restarting gnome-shell works for me.
    – krlmlr
    Commented Jan 23, 2014 at 20:49
  • sending HUP instead of QUIT makes the second command unnecessary.
    – Rich
    Commented Apr 21, 2021 at 23:19

I had a similar problem where the unlock screen wouldn't accept keyboard input sometimes. The way I finally solved it was to kill the several gnome-screensaver processes that were running, as well as one gnome-screensaver-dialog process. I'm guessing that whatever process was spawning 2 gnome-screensaver sessions was messing up my unlock screen. I'm actually supposed to be using xscreensaver instead, so maybe that messed with it.

Anyways, Ctrl+Alt+F1, look for screensaver processes running ps -aux | grep screen and kill them all. The gnome and xscreensaver commands listed in the other answers didn't work for me.

You must log in to answer this question.

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