Screenshots from the command line (scrot)

There are many Linux applications dedicated to taking screen shots. However, you might want to use the command line to do this, either because you want to build an automated script, or because you have a terminal screen handy.

Scrot (SCReenshOT) will probably not come pre-installed with your distro; so, as ever, it is a case of a quick visit to the software repositories. If that turns up a blank you should be able to download a source tarball or a pre-compiled binary at the official site.

This is not the place to launch into a detailed comparison of available screen shot tools, graphical or command line. Scrot despite being a command-line tool, offers the user an excellent screen shot tool with power options to suit most requirements. Scrot is a command-line tool (written in C and using the imlib2 library); so obviously you will be running it in a console within your X windows session.

Install
For Ubuntu/Debian:
$ sudo aptitude install scrot

For Fedora/CentOS:
$ yum install scrot

Usage
Syntax:
$ scrot mypicturefile

Example
Delay of 4 seconds between launching the command and saving the screenshot.png file.
$ scrot -d 4 screenshot.png

Display a countdown in the console.
$ scrot -c -d 4 screenshot.png

Save a JPG file with a quality of 80%.
$ scrot -q 80 -c -d 4 screenshot.jpg

You can also use special strings with scrot, as to produce filenames that contain the date and size of the screenshot:
$ scrot ‘%Y-%m-%d_$wx$h.png’ -e ‘mv $f ~/Desktop/Pictures/’
(The command above will produce a file named 2010-11-28_2560×1024.png on the system and move that file to to a folder called Pictures.)

To get a screenshot and immediately open it in the GIMP, type:
$ scrot -q 85 -d 5 screenshot.png && gimp screenshot.png &
(The -q option sets the quality. The -d sets the delay. The && means that if the first command is true, then execute the second. The final & means to run the commands in the background so that you can still use that terminal for other commands.)

For more information about using scrot, read the man pages
$ man scrot

There are several ways to take a screenshot Linux in general. Which ways do you use?

jonboy60

I’m a Malaysian, my name is Jon Loh (jonboy60) living in Kuala Lumpur and working in Petaling Jaya, Malaysia. Jonboy60.com is a blog magazine about Linux and other open source softwares. All about to a daily jobs or real life experiences I had since the year 2002 administrating Linux and Windows server in a hosting company. Basically i will be offering Linux tips, howto, tricks, latest news and tutorial. Contact Me for Career opportunities, business offers, Linux solutions for business or home, web and email server solutions, Linux consulting and expertise requests. Email to me on jonboy60{@}gmail.com. The site I’m running is VenCouture.com – Malaysia Online Fashion Shopping Boutique, VenCouture. We sell fashion clothes, sexy lingeries, baby clothing and etc.

More PostsWebsite

Follow Me:
TwitterFacebook

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

*


− 6 = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge