On tty2, how do I take a text screenshot of the command line?


If you can use tmux or screen, they have the ability to save the scrollback buffer to a file.

Unlike screendump, which is Linux-only, tmux and screen are available for BSD-based OSes too (e.g. macOS, FreeBSD) and won't require special permissions.

  • Because of that, I marked this one as accepted. But @RudiC Don't take it personally. Your solution is still the simplest. – neverMind9 Nov 25 '18 at 10:28
  • Those two add another layer; you need to login and then run screen, have another shell, and then can communicate with your CLI. – RudiC Nov 25 '18 at 11:54

Did you consider the screendump command?

  • 3
    "Just saying cat /dev/vcsN has a similar effect". Then why not just use cat /dev/vcsN? – Weijun Zhou Nov 24 '18 at 16:45
  • 5
    Try it and see. – RudiC Nov 24 '18 at 16:46
  • Nice. Is there a way to get it to do colour as well? (screendump reads from /dev/vcsa devices which does have colour information, but it seems to be stripped from the output.) Btw. I like to combine it with the watch command to see live output like watch -n0.1 screendump. – kasperd Nov 25 '18 at 13:25
  • @WeijunZhou /dev/vcs devices don't contain information about the size of the screen, so cat /dev/vcsN only works if your terminal window has the same number of characters across as the VC you are capturing. – kasperd Nov 25 '18 at 13:26

You can use script for this. It will record a typescript of the terminal session. By default, it will write to ./typescript. Of course, you need to do this in advance so it is not really a "screenshot".

$ script
Script started, file is typescript
$ ls asdf
ls: cannot access asdf: No such file or directory
$ exit
Script done, file is typescript

# Then check the recordings:

$ cat typescript
Script started on Thu 29 Nov 2018 02:52:04 PM CET

$ ls asdf
ls: cannot access asf: No such file or directory
$ exit

Script done on Thu 29 Nov 2018 02:52:09 PM CET

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.