How To Install Scrot - Take A Screenshots Automatically in Linux

To take Desktop/Server screenshots automatically using Scrot

Scrot is a command line tool which is powerfull and flexible for capturing screenshots of desktop and server by cron job. It is the same as import command which uses imlib2 to capture images. Procedure to take Desktop/Server screenshots automatically using Scrot is explained in this article.

Features

  • It is easy to use and install.
  • The quality of the screenshots image can be optimized with -q switch.
  • Particular window or area can be captured.
  • Screenshots can be stored in particular directory in remote PC or server.
  • Used to monitor PC to prevent unwanted actions.

To install Scrot

The yum and apt-get command is used to install the packages on RedHat or Debian based distribution.

On RedHat based Systems

# yum install scrot

To install from source code, execute the following commands

# wget http://linuxbrit.co.uk/downloads/scrot-0.8.tar.gz
# tar -xvf scrot-0.8.tar.gz
# cd /scrot-0.8
# ./configure
# make
# " make install" 

RedHat users should specify the prefix location using configure command.

On Ubuntu based Systems

user1@linuxhelp:~$ sudo apt-get install scrot
[sudo] password for user1: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  giblib1 libgif7 libid3tag0 libimlib2
The following NEW packages will be installed:
  giblib1 libgif7 libid3tag0 libimlib2 scrot
0 upgraded, 5 newly installed, 0 to remove and 92 not upgraded.
Need to get 264 kB of archives.
After this operation, 904 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
.
.
. 
Setting up scrot (0.8-17) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...

Take a screenshot of the whole desktop

Open a terminal and type scrot, then hit Enter.

user1@linuxhelp:~$ scrot
user1@linuxhelp:~$ ls -l
total 112
-rw-rw-r-- 1 user1 user1 68163 Jun 22 03:26 2016-06-22-032655_800x600_scrot.png
drwxr-xr-x 2 user1 user1  4096 Jun  1 00:33 Desktop
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Documents
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Downloads
-rw-r--r-- 1 user1 user1  8980 Jun  1 05:46 examples.desktop
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Music
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Pictures
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Public
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Templates
drwxr-xr-x 2 user1 user1  4096 Jun  1 05:53 Videos

The image captured will be stored in the current directory and by default its name will be in the following format.

filename_date_and_time_screen resolution_scrot.png

Also you can specify the name of your choice and image type by using this command

user1@linuxhelp:~$ scrot ~/Pictures/linuxhelp.jpg
user1@linuxhelp:~$ 
user1@linuxhelp:~$ cd Pictures/
user1@linuxhelp:~/Pictures$ ls -l
total 28
-rw-rw-r-- 1 user1 user1 26143 Jun 22 03:32 linuxhelp.jpg

The above command will capture the full desktop and save it in Pictures folder with the name linuxhelp and image type as jpg.

It also allows you to take screenshot of any selected area of the screen.

Type the command below in the terminal and hit Enter.

user1@linuxhelp:~/Pictures$ scrot -s
user1@linuxhelp:~/Pictures$ ls -l
total 76
-rw-rw-r-- 1 user1 user1 46782 Jun 22 03:40 2016-06-22-034042_735x387_scrot.png
-rw-rw-r-- 1 user1 user1 26143 Jun 22 03:32 linuxhelp.jpg

After hitting enter, drag the mouse over the area to capture and release the button.

To take a screenshot of the whole screen after a specific time, add the “ -d” (delay) argument to the scrot command with the delay time . To take a screenshot in 8 seconds, use the following format.

user1@linuxhelp:~/Pictures$ scrot -d 8 example.jpg
user1@linuxhelp:~/Pictures$ 
user1@linuxhelp:~/Pictures$ ls -l
total 104
-rw-rw-r-- 1 user1 user1 46782 Jun 22 03:40 2016-06-22-034042_735x387_scrot.png
-rw-rw-r-- 1 user1 user1 26232 Jun 22 03:44 example.jpg
-rw-rw-r-- 1 user1 user1 26143 Jun 22 03:32 linuxhelp.jpg

This will capture the whole screen exactly after 7 seconds and save it in the current directory with the name example.jpg. You can also use the parameter “ -c” in addition to “ -d” to print countdown to screenshot in the terminal.

user1@linuxhelp:~/Pictures$ scrot -d 8 -c desktop.png
Taking shot in 8.. 7.. 6.. 5.. 4.. 3.. 2.. 1.. 0.
user1@linuxhelp:~/Pictures$ 
user1@linuxhelp:~/Pictures$ ls -l
total 180
-rw-rw-r-- 1 user1 user1 46782 Jun 22 03:40 2016-06-22-034042_735x387_scrot.png
-rw-rw-r-- 1 user1 user1 75392 Jun 22 03:55 desktop.png
-rw-rw-r-- 1 user1 user1 26232 Jun 22 03:44 example.jpg
-rw-rw-r-- 1 user1 user1 26143 Jun 22 03:32 linuxhelp.jpg

It starts count down in descending order, once it reaches 0- a screenshot is taken.

To install GIMP Package

user1@linuxhelp:~/Pictures$ sudo apt-get install gimp
[sudo] password for user1: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gimp-data libamd2.4.1 libbabl-0.1-0 libblas-common libblas3
.
.
Setting up gimp (2.8.16-1ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...

You can also take a screenshot, open and edit it on the go using GIMP by combining two commands as follows.

user1@linuxhelp:~/Pictures$ scrot -q 90 -d 7 linuxhelp1.png & &  gimp linuxhelp1.png & 
[1] 4929

Explanations

The first command&rarr One for taking the screenshot with scrot (scrot -q 90 -d 7 linuxhelp1.png)

The second command&rarr is for opening the newly created screenshot image on GIMP (gimp unixmen.png).

The AND logic operator (& & ) &rarr tells the terminal “ If the first command is true, then perform the second one” .


Tag : Scrot
FAQ
Q
How to Take a screenshot of the whole desktop?
A
to Take a screenshot of the whole desktop Open a terminal and type scrot, then hit Enter.
Q
How to install scrot On Ubuntu based Systems?
A
install scrot On Ubuntu based Systems using the following command

install scrot On Ubuntu based Systems
Q
How to install Scrot On RedHat based Systems?
A
install Scrot On RedHat based Systems using the following command

yum install scrot
Q
How to make linux ubuntu show dual screens?
A
You can enable the dual screens from the Ubuntu display i.e System -> Preferences -> Display
Q
How to take the screenshot of particular website like google or any monitoring tool like backup.
A
You can use shutter tool to take screenshot of any window or selected portion of windows.