Grab a Virtual Console Screen with screendump
screendump grabs whatever text is sitting on a Linux virtual console right now and writes it straight to a file. That is the whole trick, and it only works on a real kernel virtual console. The guide uses screendump from kbd 2.6.4-2ubuntu2, installed on the system used for these examples. Allow about ten minutes, plus local access to a real virtual console such as one reached with Ctrl+Alt+F3.
The route
Jump straight to the step you need, or tick off Done means at the end.
Checkpoint
This command reads a kernel virtual console. It does not capture a graphical desktop, a terminal emulator window, an SSH session or a multiplexer pane. If you are working in one of those, switch to the actual virtual console before diagnosing a failure.
1. Check the installed command
Confirm which executable and package version you will use first. These are ordinary, read-only commands and need no elevated privileges:
$ command -v screendump
/usr/bin/screendump
$ dpkg-query -W -f='${Package} ${Version}\n' kbd
kbd 2.6.4-2ubuntu2
The installed manual describes exactly one optional argument, N. With no argument, screendump selects the current virtual console. With an argument, it selects virtual console N. There are no documented long or short capture options to add on top.
2. Choose the console number
Move to the console whose contents you need and note its number. Ctrl+Alt+F3 normally lands on virtual console 3, but the function-key mapping is host-specific: do not infer the number from the terminal window where you started the command.
- Capturing the current console? Omit the argument entirely.
- Capturing a console you have already checked? Replace
CONSOLE_NUMBERwith that number:
$ screendump CONSOLE_NUMBER > console.txt
The redirection sends standard output to console.txt. There is no progress report: the captured screen contents are the output. A successful run leaves the shell prompt ready for the next command, with no extra diagnostic text.
3. Verify the capture without touching the console
Check that the destination exists and is not empty:
$ test -s console.txt && echo 'capture has data'
capture has data
$ wc -c console.txt
384 console.txt
The byte count is only an example and depends on the console's dimensions and contents. Run sed -n '1,20p' console.txt to inspect the first lines as text. This is a plain screen dump, not a screenshot: the command reads the virtual-console screen device, while the related vcsa device is the form that also carries attributes.
Checkpoint
Compare the visible text on the selected console with the saved file. A non-empty file proves that bytes came back, not that you selected the right console.
4. Capture the console you are actually on
Already sitting on the target virtual console? The shorter form avoids carrying a possibly wrong number:
$ screendump > current-console.txt
$ wc -c current-console.txt
384 current-console.txt
Run that command on the virtual console itself. In a graphical terminal or an SSH connection, "current" does not mean the console you are looking at, and the command can fail simply because that session is not attached to a console device.
5. Handle permissions safely
For security reasons, screendump relies on virtual-console device files such as /dev/vcsN and /dev/vcsaN. The manual says those devices need suitable permissions, or the command must run as root. Inspect the device files before changing anything:
$ ls -l /dev/vcs* /dev/vcsa* 2>/dev/null
$ id
If you see Permission denied, do not immediately loosen device permissions. Reading a console can expose another user's commands, prompts or secrets. If you have an approved administrative reason, run the one capture with elevated privileges and write the result somewhere protected:
$ sudo screendump CONSOLE_NUMBER > console.txt
$ sudo chown -- "$USER:$USER" console.txt
The first command elevates only screendump; the shell already created console.txt before that command started. The second changes the file's owner, and also needs privilege if root created the file. If the capture holds credentials or personal data, restrict or securely remove it under your local policy.
Warning
Do not make /dev/vcs* world-readable as a quick fix. That turns a one-off permission problem into a standing way for any local user to read other people's consoles.
6. Diagnose the common failures
An ioctl error, or a complaint about /dev/ttyN, means you are on a pseudo-terminal rather than a Linux virtual console. Run tty to see the session device, then switch consoles and retry. A terminal emulator commonly reports a path such as /dev/pts/2, which is not the virtual console that screendump reads:
$ tty
/dev/pts/2
$ screendump
/dev/tty0: Permission denied
screendump: ioctl TIOCGWINSZ: Inappropriate ioctl for device
The exact error text varies with the session and permissions. This failure does not mean the virtual console is blank: it means the current session is not a usable console context, or the required device cannot be opened.
If the capture is empty or contains unexpected text, verify the console number and repeat the comparison from step 3. A command actively writing to the console means the capture is only a point-in-time read and can change between checks. No service is stopped and no console state is modified by screendump itself.
Done means
screendumpcomes from the expected kbd package and version.- You selected a real Linux virtual console, or deliberately captured the current one.
- The output file is non-empty and matches the visible console contents.
- Any elevated capture was justified, and the output is protected because it may hold sensitive text.
- You left virtual-console device permissions and system configuration untouched.