25

Is there a way for me to take a screenshot in a virtual console?

ændrük
  • 78,726

2 Answers2

22

There's an application called fbgrab provided by the fbcat package that (as the name might suggest) grabs a shot of the current framebuffer. This might not work on newer KMS setups.

sudo apt-get install fbcat
fbgrab screenshot.png

If that fails, you could always use a VM in VirtualBox.


If you want to take a picture of another TTY, fbgrab takes a -c N argument (where N is replaced with the /dev/ttyN you're using).

So if you wanted tty1:

sudo fbgrab -c 1 Desktop/tty-screenshot.png
Oli
  • 299,936
  • 1
    When I try fbgrab foo.png it says Error: Couldn't open /dev/fb0.. Any idea why? – trusktr Nov 19 '12 at 22:24
  • 3
    @trusktr I know this is late, but it may be because you aren't in the video group. Try editing the file /etc/group, and adding your username to the end of the line that starts with "video". If that doesn't work, try using the app as root – Braden Best Jan 01 '14 at 02:42
  • @B1KMusic Thanks, I'll have to try it when my new laptop arrives next week. I have Windows in the interim. – trusktr Jan 19 '14 at 05:29
  • 1
    I had to use sudo -E fbgrab vt1.png. But it worked great. – isomorphismes Jun 10 '15 at 04:19
  • The best answer so far and it worked! – Smeterlink Aug 17 '22 at 15:18
  • For some reason I got a random noise texture in my screen's resolution after the lock screen flashing for a split-second on my screen when I fbgrab'd tty1. The random noise may have something to do with the fact that I tried writing stuff to /dev/fb0 before to see if it would appear anywhere, but it let the lockscreen repaint so I don't know why I got random noise still… – Lampe2020 Oct 01 '24 at 17:17
20

To take a screenshot of the first virtual console (AKA screendump) and save it to a file called "screenshot":

sudo cat /dev/vcs1 > screenshot

Using this method, the screenshots are saved in plain text format, not an image (check this with file or mimetype command). It simply outputs a screen dump and then EOF. Note that the output does not contain newline characters, so some processing may be required:

sudo cat /dev/vcs1 | fold  > screenshot

fold wrap each input line to fit in specified width (80 by default).

You cannot take the screenshot of a virtual console when graphics is enabled.

Reference

Pablo Bianchi
  • 17,552
Sid
  • 10,643
  • 2
    what do you mean text format? The RGB values are saved in a text file, or the text contents of the terminal is saved? Usually people want a screenshot to capture some visual bug which doesn't transfer to encoded character output. – jiggunjer Feb 23 '17 at 02:31
  • What does "graphics enabled" refer to? – RokeJulianLockhart Apr 09 '25 at 14:52