System Servicesclipboardx11x selectionscommand line

xclip

xclip is a command line utility for accessing X server selections (clipboard) on X11 systems. It reads data from stdin or files to place in X selections or prints selections to stdout.

Description

xclip provides a command line interface to X selections, known as the clipboard, on systems with X11 implementations. It enables users to read data from standard input or files and place it into an X selection for pasting into other X applications. Conversely, it can print an X selection to standard output, allowing redirection to files or other programs.

This tool is particularly useful for scripting clipboard operations in terminal environments, facilitating seamless data transfer between command line processes and graphical X applications. The xclip package also includes companion tools like xclip-copyfile, xclip-cutfile, and xclip-pastefile for file operations via the X clipboard.

Installed size is 62 KB, with dependencies including libc6, libx11-6, libxmu6, and xclip itself.

How It Works

xclip interfaces directly with the X11 server to read from or write to X selections such as 'primary', 'secondary', 'clipboard', or 'buffer-cut'. It connects to a specified X display, handles selection requests with configurable loops, and processes data via stdin/stdout or files, leveraging X11 protocols for clipboard operations.

Installation

bash
sudo apt install xclip

Flags

-i, -inread text into X selection from standard input or files (default)
-o, -outprints the selection to standard out (generally for piping to a file or program)
-l, -loopsnumber of selection requests to wait for before exiting
-d, -displayX display to connect to (eg localhost:0)
-h, -helpusage information
-selectionselection to access ("primary", "secondary", "clipboard" or "buffer-cut")

Examples

Display usage information for xclip
xclip -h
Read text into X selection from standard input (default behavior)
xclip -i
Print the X selection to standard output
xclip -o
Connect to specified X display
xclip -d localhost:0
Access the clipboard selection
xclip -selection clipboard
Show help for xclip-copyfile (copy and move files via X clipboard)
xclip-copyfile --help
Show usage for xclip-pastefile
xclip-pastefile -h
Updated 2026-04-16kali.org ↗