Recently, we discussed about the[gnome-screenshot][17]utility, which is a good screen grabbing tool. But if you are looking for an even better command line utility for taking screenshots, then you must give Scrot a try. This tool has some extra features that are currently not available in gnome-screenshot. In this tutorial, we will explain Scrotusing easy to understand examples.
Please note that all the examples mentioned in this tutorial have been tested on Ubuntu 16.04 LTS, and the scrot version we have used is 0.8.
### About Scrot
[Scrot][18](**SCR**eensh**OT**) is a screenshot capturing utility that uses the imlib2 library to acquire and save images. Developed byTom Gilbert, it's written in C programming language and is licensed under the BSD License.
### Scrot Installation
The scrot tool may be pre-installed on your Ubuntu system, butifthat's not the case, then you can installit using the following command:
sudo apt-get install scrot
Once the tool is installed, you can launch it by using the following command:
scrot [options] [filename]
**Note**: The parameters in [] are optional.
### Scrot Usage/Features
In this section, we will discuss how the Scrot tool can be used and what all features it provides.
When the tool is run without any command line options, it captures the whole screen.
By default, the captured file is saved with a date-stamped filename in the current directory, although you can also explicitly specify the name of the captured image when the command is run. For example:
scrot [image-name].png
### Get the applicationversion
If you want, you can check theversion of scrot using the-vcommand line option.
Using the utility, you can limit the screenshot to the currently focused window. This feature can be accessed using the-ucommand line option.
scrot -u
For example, here's my desktop when I executed the above command on the command line:
[
![capture window in scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/desktop.png)
][21]
And here's the screenshot captured by scrot:
[
![Screenshot captured by scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/active.png)
][22]
### Selecting a window
The utility allows you to capture any window by clicking on it using the mouse. This feature can be accessed using the-soption.
scrot -s
For example, as you can see in the screenshot below, I have a screen with two terminal windows overlapping each other. On the top window, I run the aforementionedcommand.
Now suppose, I want to capture the bottom terminal window. For that, I will just click on that window oncethe command is executed - the command execution won't complete until you click somewhere on the screen.
Here's the screenshot captured after clicking on that terminal:
**Note**: As you can see in the above snapshot, whatever area the bottom window is covering has been captured, even if that includes an overlapping portion of the top window.
### Includewindow border in screenshots
The-ucommand line option we discussed earlier doesn't include the window border in screenshots. However, you can include the border of the window if you want. This featurecan be accessedusing the-boption (in conjunction with the-uoption of course).
scrot -ub
Here is an example screenshot:
[
![include window border in screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/border-new.png)
][25]
**Note**: Including window borderalso adds some of the background area to the screenshot.
### Delay in taking screenshots
You can introduce a time delay while taking screenshots. For this, you have to assign a numeric value to the--delayor-dcommand line option.
Using the tool, you can adjust the quality of the screenshot image at the scale of 1-100\. High value means high size and low compression. Default value is 75, althougheffect differs depending on the file format chosen.
This feature can be accessed using--qualityor-qoption, but you have to assign a numeric value to this option ranging from 1-100.
So you can see that the quality of the image degrades a lot as the-qoption is assigned value closer to 1.
### Generating thumbnails
The scrot utility also allows you to generate thumbnail of thescreenshot. This feature can be accessed using the--thumboption. This option requires a NUM value, whichis basically the percentage of the original screenshot size.
scrot --thumb NUM
scrot --thumb 50
**Note**: The--thumboption makes sure that the screenshot is captured and saved in original size as well.
For example, here is the original screenshot captured in my case:
![thumbnail of the screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/thmb.png)
][30]
### Join multiple displays shots
In case your machine has multiple displays attached to it, scrot allows you to grab and join screenshots of thesedisplays. This feature can be accessed using the-mcommand line option.
Using the tool, we can execute various operations on saved images - for example, open the screenshot in an image editor like gThumb. This feature can be accessed using the-ecommand line option. Here's an example:
scrot abc.png -e ‘gthumb abc.png’
Here, gthumb is an image editor which will automatically launch after we run the command.
Following is the snapshot of the command:
[
![Execute commands on screenshots](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec1.png)
So you can see that the scrot command grabbed the screenshot and then launched the gThumb image editor with the captured image as argument.
If you don’t specify a filename to your screenshot, then the snapshot will be saved witha date-stamped filename in your current directory - this, as we've already mentioned in the beginning, is the default behaviour of scrot.
Here's an-ecommand line option example where scrot uses the default name for the screenshot:
It's worth mentioning that$nis a special string, which provides access to the screenshot name. For more details on special strings, head tothe next section.
### Special strings
The-e(or the--exec) andfilenameparameters can take format specifiers when used with scrot. There are two types of format specifiers. First type is characters preceded by ‘%’ that are used for date and time formats, while the second type is internal to scrot and are prefixed by ‘$’
Several specifiers which are recognised by the--execandfilenameparameters are discussed below.
**$f**– provides access to screenshot path (including filename).
If you will not specify afilename, then scrot will by-default save thesnapshot in a date stamped file format. This is the by-default date-stamped file format used in scrot :%yy-%mm-%dd-%hhmmss_$wx$h_scrot.png.
**$n**– provides snapshot name. Here is an example snapshot:
Similarly, you can use the other special strings**$p**,**$w**,**$h**,**$t**,**$$**and**\n**that provide access to image pixel size, image width, image height, image format, $ symbol, and give access to new line respectively. You can, for example, use these strings in the way similar to the**$s**example we have discussed above.
### Conclusion
The utility is easy to install on Ubuntu systems, which is good for beginners.Scrot also provides some advanced features such as special strings that can be used in scripting by professionals. Needless to say, there is a slight learning curve associated in case you want to use them.