Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use commands to take screenshots under Linux graphical interface

Shulou Source: shulou.com Published: 2022-06-01 15:32:15 10月04日 Update

This article introduces the relevant knowledge of "how to use commands to take screenshots under the Linux graphical interface". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In the past, screenshots in LINUX were taken by directly pressing the print screen key or alt + print screen.

But print screen is the whole screen, and alt + print screen is the current window.

What do you want to use to capture an area of the screen?

The answer is the import command, enter:

The code is as follows:

$import ddd.jpg

Then the mouse will become "+", just like the screenshot tool of QQ, it is convenient to OK as soon as you drag it.

Screenshot of login interface

In daily use, we take screenshots after logging in to the system, such as capturing a window, a specified area, or an entire web page. It's a bit complicated to take a screenshot of the login interface, which is what you need to do before you log in.

Use these commands to capture a screenshot of the login interface under root permissions:

The code is as follows:

Chvt 8

Sleep 5

DISPLAY=:0.0 XAUTHORITY=/var/lib/mdm/:0.Xauth xwd-root > / tmp/shot.xwd

Convert / tmp/shot.xwd / tmp/ss.png

The most critical part of these commands is the third line of XAUTHORITY=/var/lib/mdm/. Different distributions use different login managers by default. For example, Ubuntu uses lightdm,Kubuntu, kdm,Linux Mint uses mdm, and distributions with Gnome as the desktop environment use gdm.

The corresponding XAUTHORITY is different for different login managers. So among the materials found on the Internet, some are XAUTHORITY=/var/run/lightdm/root/, and some are XAUTHORITY=/var/lib/gdm/. So the question is, how do we determine which login manager is used by the current system?

Of course, you can't pat the head, you have to have a reason. At first, I used to think that the dm I was using was kdm, but I fell into the pit.

In fact, it is very simple, you only need to take a look at the process whose name contains dm, and you can determine how to write the command.

This is the end of the content of "how to use commands to take screenshots under the Linux graphical interface". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Screenshot login command interface different management graphics some code content area screen is in more knowledge system release complex practical learned Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Shulou Information OPPO Reno Apple