There are loads of screenshot utilities available for Linux, and many of them are very good. That’s why it seems sort of odd that none of them are capable of taking a screenshot of the login screen. That’s really just not how Linux works.
There are a couple of ways to get that illusive screenshot, though. One is much easier than the other, but it doesn’t allow you to capture your customized screen. The second option is more involved, but it can grab a shot of just about any login screen. Whichever way you choose, it’s entirely possible to take full resolution images of your Linux login screen.
Before you get into this process, it’s much easier to just take a screenshot of a virtual machine. If you’re running virtual machines on your system, especially if you’re using virt-manager or VirtualBox, you can easily take a screenshot using the utilities built in to those applications. There really isn’t a need to go any deeper.
With a Script
Warning: This method does not work with any system running Wayland. As of now, that includes a lot of distributions running GNOME, including Ubuntu. If you have GNOME and Wayland, the virtual machine method is best.
There is a way to take a screenshot of the login screen from within the same system, though. It’s just a bit more involved, and you need to write a short script to do it. This guide assumes that you’re using some variant of Ubuntu or Debian, but you can certainly adapt it to other systems. All of this is fairly universal.
The script that you’re going to write requires a common application called ImageMagick. It’s so common that it might already be installed on your system. Either way, try installing it before you do anything else.
sudo apt install imagemagick
Create Your Script
Now that you have ImageMagick, you can create your script. It’s relatively short, and it’s designed to use ImageMagick to take a screenshot of a specific application. In this case, it’s your login manager. On current Ubuntu and Debian systems, that login manager is GDM.
Open the text editor of your choosing and create a new file for your script. You can name it anything, just give it the “.sh” extension. Make that file look like the example below.
#! /bin/bash chvt 7 DISPLAY=:0 XAUTHORITY=/var/lib/gdm/$DISPLAY.Xauth xwd -root
If you’re using an Ubuntu system that’s still using Unity, or you’re on a different desktop environment, you probably have the LightDM manager instead. The script for that one looks a bit different.
#! /bin/bash chvt 7 DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/$DISPLAY xwd -root
That’s it. Save your file and exit. Before you can run your file, make sure that’s executable.
chmod +x loginscreen.sh
Take the Shot
Unfortunately, you can’t just run that script. You need to make sure that the login screen is up, and still have access to a terminal. There are a couple of ways to do that. If you’d prefer SSH, you probably already know what to do. If not, you can follow these steps.
1. First, log out. Once you see the login screen, press Ctrl + Alt + F1. That will take you to the terminal.
2. Now that you’re in the terminal, log in to your user account. Then, change into the directory with your script and run it.
sudo ./loginscreen.sh > login-screenshot.xwd
The last part of that command directs the output of the command into a file. That file is the screenshot.
Convert the Format
The last step of this process requires that you convert the file format to something more usable. ImageMagick has you covered there. It has built-in commands to help you convert the image. Remember to change the ownership of the image first.
sudo chown user:user login-screensh.xwd convert login-screenshot.xwd login-screenshot.png
Now, press Ctrl + Alt + F7 to return to your normal desktop. You’ll find your converted screenshot in the same directory where you created your script.