Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

How can I take a screenshot of the login screen?

I do not want to recreate my Ubuntu installation in a virtual machine.

share|improve this question
The first thing I would look for is something that captures the output of X. A search for "screenshot xserver" leads me to this answer on – Lekensteyn May 17 '11 at 17:45
This related discussion might be relevant: – Waldir Leoncio Oct 22 '13 at 19:20
I have shared a script to do this, in this… – Nafis Ahmad Apr 14 '14 at 9:53
up vote 13 down vote accepted

This blog might be helpful:

Install ImageMagick for the image file format conversion below:

sudo apt-get install imagemagick

Create a helper script:

echo 'DISPLAY=:0 XAUTHORITY=/var/lib/gdm/:0.Xauth xwd -root' >/tmp/

Make sure your login screen is active (log out or reboot the machine, and wait until you see the login screen). Log in in text mode (by pressing Ctrl-Alt-F1), or using SSH. Create the screen shot by running

sudo bash /tmp/ >/tmp/shot.xwd

You can log in now (by pressing Ctrl-AltF7 first to get back to the GDM login screen). Convert the screen shot to JPEG and/or PNG:

convert -quality 50 /tmp/shot.xwd /tmp/shot.jpg
convert /tmp/shot.xwd /tmp/shot.png

View the screen shot in your favourite image viewer.

share|improve this answer
I ended up using sudo sh -c 'sleep 5s; xwd -display :0 -root | convert - screenshot.png' from a virtual console and switching to the login screen during the 5-second sleep. – ændrük May 17 '11 at 23:23
I tweaked this for lightdm. $ echo 'DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root' >/tmp/ – popey Jun 10 '12 at 17:03

For 11.10 and Lightdm and later

You can try running unity-greeter --test-mode in a terminal. It displays the login screen within the session. You can then take a screenshot of the login screen like you normally do with any other application.

enter image description here

share|improve this answer
but thats too generic, any modifications cannot be see . is there any way to test current modifications ? – Ubuntuser May 12 '12 at 7:35
@Ubuntuser Not that I know of. Which modification are you testing for? – jokerdino May 12 '12 at 7:44
i am testing fingerprint reader . on login screen and the lock screen it displays nicely. i want to take a screenshot of both. – Ubuntuser May 12 '12 at 8:09
@Ubuntuser I am guessing the modifications you made affects the lightdm directly and not the Unity-greeter? I am not sure. I am just speculating. You might want to ask a new question.. – jokerdino May 12 '12 at 8:14

For Ubuntu 14.04

The answers above did not work for me in Ubuntu 14.04 - I searched around and found this that works.

  1. Install ImageMagick

    sudo apt-get install imagemagick
  2. Create a file in your home directory named preferably in your home folder and paste the following code inside it:

    chvt 7;
    sleep 5s;
    DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out ~/screenshot.xwd;
    convert ~/screenshot.xwd ~/screenshot.png;
    rm ~/screenshot.xwd
  3. Make it executable

    sudo chmod +x
  4. Logout of the system. Press Ctrl+Alt+F1 to go to the console (tty1) and login. Run the script using this command:

    sudo ./

It will take you back to login screen graphical interface (chvt 7) and after five seconds it will take and save the screenshot in your home directory with a file name screenshot.png.

Here's mine:

enter image description here


share|improve this answer
like a charm, thanks :) – versvs Aug 8 '15 at 18:12

Just wanted to note that I had a bunch of problems doing this on Ubuntu 10.04 LTS with this - here's my solution:

I'm on machine A, and I log on to machine B via ssh:

myusername@pcA:~$ ssh pcB
myusername@pcB's password: 
Linux pcB 2.6.32-44-generic #98-Ubuntu SMP Mon Sep 24 17:32:45 UTC 2012 i686 GNU/Linux
Ubuntu 10.04.4 LTS

Welcome to Ubuntu!
 * Documentation:


Then, I proceed with several attempts to grab screenshot, which all failed. The problem can be reduced down to xwininfo being unable to probe for the window state:

myusername@pcB:~$  xwininfo
xwininfo:  unable to open display ''

myusername@pcB:~$ sudo xwininfo
[sudo] password for myusername: 
xwininfo:  unable to open display ''

myusername@pcB:~$ DISPLAY=:0.0 xwininfo
No protocol specified
xwininfo:  unable to open display ':0.0'

myusername@pcB:~$ DISPLAY=:0 xwininfo
No protocol specified
xwininfo:  unable to open display ':0'

Well, it turns out that for some reason, the correct invocation for targeting X-windows via ssh is DISPLAY=:0.0 sudo xwininfo ... - that is, the DISPLAY=:0.0 environment variable goes first; the sudo goes second - and then the corresponding X command:

myusername@pcB:~$ DISPLAY=:0 sudo xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

myusername@pcB:~$ DISPLAY=:0.0 sudo xwininfo -root

xwininfo: Window id: 0x109 (the root window) (has no name)

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1366
  Height: 768
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1366x768+0+0

Now that we know xwininfo can probe the state, there is also no problem with capturing the screenshot via xwd:

myusername@pcB:~$ DISPLAY=:0.0 sudo xwd -root > /tmp/shot.xwd
share|improve this answer

Type this in a terminal:

dm-tool add-nested-seat --fullscreen

That's it! take a screenshot as usual

Press Alt + F4 to close the fullscreen window of your login screen

share|improve this answer

I edited "/etc/mdm/Init/Default" and added:

scrot -d 5 -e 'mv $f /root' &

before the line with "exit 0".

The next time I login, I count to five, beep, and I got my screenshot in "/root".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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