How to take a screenshot of the login screen in Linux

There are many screen capture utilities available for Linux and most work very well. But strangely, none of these tools have the ability to take a screenshot of the login screen.

There are many screen capture utilities available for Linux and most work very well. But strangely, none of these tools have the ability to take a screenshot of the login screen.

However, there are still some ways to get screenshots in Linux logon. Today's article will introduce you to 2 ways to do this. Method 1 is much easier than way 2, but it does not allow users to take custom screenshots. The second option is much more useful and can capture any login screen. Whichever way you choose, it is perfectly possible to take a screenshot of the Linux login screen with full resolution.

2 ways to take screenshot of login screen in Linux

  1. Capture screen login in Linux using virtual machine
  2. Capture screen login in Linux with a script
    1. Install ImageMagick
    2. Create script
    3. Screen capture
    4. Convert format

Capture screen login in Linux using virtual machine

Before proceeding through this tool, you should know that it is much easier to just take a screenshot of a virtual machine. If you are running virtual machines on the system, especially if it is virt-manager or VirtualBox, users can easily take screenshots using the built-in utilities in those applications. There is really no need to do anything bigger.

Capture screen login in Linux with a script

Warning : This method does not work with any system running Wayland. Up to now, this method is not applicable for many distributions running Gnome, including Ubuntu. If you are using Gnome and Wayland, virtual machine method is the best choice.

However, there is a way to take a screenshot of the login screen from within the same system. Just write a short script to do this. This tutorial assumes that the user is using a version of Ubuntu or Debian, but can apply the same to other systems.

Install ImageMagick

The script to write requires a common application called ImageMagick. Chances are it has been installed on your system. Either way, remember to install this tool before doing anything else.

 sudo apt install imagemagick 

Create script

Now, Linux has been installed ImageMagick. You can start creating your script. It is relatively short and designed for using ImageMagick to take screenshots of a specific application. In this case, the application is the login manager. On current Ubuntu and Debian systems, the login manager is GDM.

How to take a screenshot of the login screen in Linux Picture 1How to take a screenshot of the login screen in Linux Picture 1

Open your favorite text editor and create a new file for the script. Users can name them freely but remember to provide file name extensions. Do the same as the example below:

 #! /bin/bash chvt 7 DISPLAY=:0 XAUTHORITY=/var/lib/gdm/$DISPLAY.Xauth xwd -root 

If you use an Ubuntu system and still use Unity or on another desktop environment, you may have a LightDM manager instead of GDM. However, the script will be slightly different.

 #! /bin/bash chvt 7 DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/$DISPLAY xwd -root 

Save the file and exit. Before running the script file, make sure it is executable.

 chmod +x loginscreen.sh 

Screen capture

Unfortunately, it is not possible to run that script alone. You need to make sure that the login screen is on and still has access to the terminal. There are several ways to do that. If you've ever used SSH, you probably already know what to do. If not, follow these steps.

How to take a screenshot of the login screen in Linux Picture 2How to take a screenshot of the login screen in Linux Picture 2

1. First, log out. When you see the login screen, press Ctrl + Alt + F1 . This step will take you to the terminal.

2. You are now in the terminal. Please log in to the user account, then change the directory with the 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 a screenshot.

Convert format

How to take a screenshot of the login screen in Linux Picture 3How to take a screenshot of the login screen in Linux Picture 3

The final step of this process requires converting the file format into something easier to use. ImageMagick can do this. It has built-in commands that help users convert images. Remember to change the ownership of the image first.

 sudo chown user:user login-screensh.xwd convert login-screenshot.xwd login-screenshot.png 

How to take a screenshot of the login screen in Linux Picture 4How to take a screenshot of the login screen in Linux Picture 4

Now press Ctrl + Alt + F7 to return to the normal screen. You will find a converted screenshot in the same directory where the script was created.

Good luck!

See more:

  1. How to take a screenshot of the website
  2. How to capture login screen and lock screen in Windows 10
  3. How to take a picture of the entire website on Coc Coc browser
4.4 ★ | 7 Vote