Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Friday, January 3, 2020 at 17:38

There are not many clear tutorials available in taking picture of the login screen of latest Ubuntu, Mint, and elementary OS. Their login screen technology is called LightDM. You cannot simply press Printscreen key in the login screen to create its screenshot. Instead, you need a complicated way with superuser access to do so. This might give you frustration if you do not know the way especially if you are a writer like me. Fortunately, it is easy and everybody can do it like my explanations below. You can do this both in LiveCD session and in an installed system. I write this tutorial by testing it first on elementary OS 5.1 Hera that released recently at the end of 2019. After a long time, I am happy to finally figure out this method. Enjoy!

Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.

Important to Know

You need to know 4 things:

  • 1) Xorg server within your system, 
  • 2) the address of the screen, 
  • 3) the file path of Xauthority, and 
  • 4) the actual command that capture the screenshot. 

Explanations about these are available at the end.


In this tutorial, I use elementary OS Hera, in which the TTY is located at Ctrl+Alt+F2 up to Ctrl+Alt+F6 while the Graphical Desktop is located at Ctrl+Alt+F7. This means in elementary OS, tty2 up to tty6 are console and tty7 is the desktop. Other GNU/Linux distros are just the same or at least similar you can figure it out by yourself. You need to note where is the console tty and where is the desktop one.

1. Create Script

Write this code as file with text editor program.
$ sleep 10s; DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out ~/loginscreen.xwd; convert ~/loginscreen.xwd ~/loginscreen.png; rm ~/loginscreen.xwd

I would love to say thank you to Karim Buzdar from as he enlightened me with this script, a collection of 4 different commands, that works.

Explanation also goes below at the end.

2. Logout Graphically

Exit from your desktop session so you can see your login screen.

3. Login to TTY

  • Press Ctrl+Alt+F2 so you can see your tty2.
  • You are asked to login here.
  • Type your username.
  • Type your password.
  • You logged in at tty2.

4. Run Script from TTY

$ sudo ./

5. Go To Graphic Login Screen

Press Ctrl+Alt+F7 so you see your login screen once again.

6. Wait

Wait for 10 seconds as the script says.

7. Login Graphically

Login to your desktop with your username.

8. Result

You find a new picture in your Home folder that is the screenshot of your login screen. Congratulations!


Here I am trying to explain 2 things, first the important things from the beginning and second the meaning of the commands used above. 

The important things:

This tutorial works with Xorg-based system but not in Wayland-based system. Ubuntu, Mint Cinnamon, and elementary OS latest versions are all Xorg-based. So this tutorial should works there. Figure this out by command line: $ ps aux | grep -i xorg .

The address of the screen is like :0 or :1 or :2, that is the name of graphical desktop according to the operating system. You will figure this out by invoking command line: $ echo $DISPLAY .

The Xauthority file is located under folder: /var/run/lightdm/root/ with file name like :0 or :1 or :2. Yes, it might look strange but it is true.

On GNU/Linux, there is a unique command called xwd, that "dumps an image of an Xorg Window", which means we can use to dump a picture of Login Screen. However, the image file produced is still need to be converted so we could see it.

The commands:

$ sleep 10s;
This is a command to delay the execution of the next command. The delay is 10 seconds. The purpose is to give you enough time to switch from tty console into Graphical Login Screen and wait there. You may change it to 20 or 30 if you like.

DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out ~/loginscreen.xwd;
The actual command is xwd -root -out ~/[filename].xwd and the two long variables before it are important signs that first determine this command to work in :0 address and second determine the Xauthority file that related to that address. These are the requirements for xwd to capture the screen.

convert ~/loginscreen.xwd ~/loginscreen.png;
This is an ImageMagick command to convert raw picture in .xwd format into a PNG picture. Fortunately, elementary OS Hera includes it by default.

rm ~/loginscreen.xwd
This is the last command to delete the remaining .xwd file as we do not need it.

This article is licensed under CC BY-SA 3.0.