Copying text from a terminal - ArchWiki

# Copying text from a terminal

Most mature terminal emulators permit users to copy or save their contents.

## General approach

In graphical terminal emulators, contents are typically selectable by mouse, and can then be copied using the context menu, Edit menu or a key combination such as `Ctrl+Shift+C`.

### Terminals without CLIPBOARD selection

Some emulators do not support the CLIPBOARD selection natively, and copy data to the PRIMARY selection. For them xclip may be used:

    $ xclip -o | xclip -selection clipboard -i

The above command reads data from the PRIMARY selection and writes it to CLIPBOARD selection.

Other clipboard managers such as autocutsel provide automatic synchronization between selection buffers.

### Intercepting commands’s output

Use tee to intercept the output of a command.

    $ command 2>&1 | tee output-file

After the `command` is executed, `output-file` will contain its output.

### Accessing Linux terminal backlog

The backlog of a native terminal named `/dev/ttyN` may be accessed via `/dev/vcsN`. Hence, if one is working in `/dev/tty1`, the following snippet will let store the backlog in a file `output-file`:

    # cat /dev/vcs1 >output-file

## A cheatsheet for common emulators

The factual accuracy of this article or section is disputed.

Reason: Some "No" entries in this table may be wrong. (Discuss in Talk:Copying text from a terminal#A cheatsheet for common emulators: "No" entries factual accuracy)

Unless the "Notes" column states otherwise, the keys combination is `Ctrl+Shift+c`.

Emulator | Selection → PRIMARY | Selection → CLIPBOARD
--- | --- | ---
Automatic | Keys combination | Context menu → Copy | Window menu → Copy | Notes
atermAUR | Yes | No | No | No | No |
ETermAUR | Yes | No | No | No | No |
germinalAUR | Yes | No | Yes | Yes | No |
guake | Yes | No | Yes | Yes | No |
konsole | Yes | No | Yes | Yes | Yes |
lilyterm | Yes | No | Yes | Yes | No | `Ctrl+Delete`
lxterminal | Yes | No | Yes | Yes | Yes |
mate-terminal | Yes | No | Yes | Yes | Yes |
mltermAUR | Yes | Yes | No | No | No |
pantheon-terminal | Yes | No | Yes | Yes | No |
putty | Yes | No | No | No | No |
qterminalAUR | Yes | No | Yes | Yes | Yes |
roxterm | Yes | No | Yes | Yes | Yes |
rxvt | Yes | No | No | No | No |
sakura | Yes | No | Yes | Yes | Yes |
st | Yes | No | No | No | No |
terminator | Yes | No | Yes | Yes | No |
terminology | Yes | No | Yes | Yes | No |
termite | Yes | No | Yes | No | No |
tilda | Yes | No | Yes | Yes | No |
tinyterm-gitAUR | Yes | No | Yes | No | No |
urxvt | Yes | Optional | Yes | No | No | `Ctrl+Alt+c`
xfce4-terminal | Yes | No | Yes | Yes | Yes |
xterm | Yes | Yes | Optional | No | No | [1]
yakuake | Yes | No | Yes | Yes | No |

## Special cases

### putty

The xclip approach works for putty: one just has to remember that the xclip invocation should be done on the local computer (in another terminal), not on the remote machine to which putty is connected.

### urxvt

Selecting text to CLIPBOARD requires the `selection-to-clipboard` perl extension. See Rxvt-unicode#Cut and paste for details.

### xterm

Access to the CLIPBOARD selection in xterm requires additional steps.

Category:

- Command shells

Hidden category:

- Pages or sections flagged with Template:Accuracy