How To Copy And Paste In Ubuntu

11 min read

Copy and paste operations form the backbone of daily computing workflows, yet the way they function in Ubuntu often surprises users migrating from Windows or macOS. Which means while the basic concept remains identical—duplicating data from a source to a destination—the implementation details, keyboard shortcuts, and clipboard management in Linux desktop environments carry unique nuances. Mastering these methods transforms a frustrating experience into a seamless, efficient process, whether you are editing code in a terminal, moving files in the file manager, or transferring text between applications That's the whole idea..

Understanding the Two Clipboards: Primary vs. Clipboard

Before diving into shortcuts, it is critical to understand a fundamental difference between Linux and other operating systems. Ubuntu (and Linux in general) traditionally utilizes two distinct clipboard buffers managed by the X Window System (X11) or Wayland protocols Small thing, real impact..

  1. The Primary Selection (Highlight Buffer): This is the "Linux superpower." Whenever you highlight text with your mouse cursor (click and drag), that text is automatically copied to the Primary Selection buffer. No keyboard shortcut is required. You paste this buffer by clicking the middle mouse button (or pressing the scroll wheel) at the target location. This allows for incredibly fast "highlight-to-paste" workflows without ever touching the keyboard.
  2. The Clipboard Selection (Ctrl+C / Ctrl+V Buffer): This behaves exactly like the clipboard on Windows or macOS. You must explicitly copy (usually Ctrl+C) or cut (Ctrl+X), and explicitly paste (Ctrl+V). This buffer is used for deliberate, persistent copy-paste actions.

Crucial Note: These two buffers are independent. You can have different text stored in each simultaneously. Highlighting text does not overwrite your explicit Ctrl+C clipboard, and Ctrl+C does not overwrite your highlighted selection. Modern Wayland sessions (default in Ubuntu 22.04+) handle this more uniformly, but the middle-click paste behavior often persists in terminal emulators and specific applications.

Graphical Interface (GUI) Methods

For most daily tasks inside the GNOME desktop environment (Ubuntu's default), standard shortcuts apply, though with a few caveats.

Standard Keyboard Shortcuts

Inside almost all graphical applications—web browsers (Firefox, Chrome), text editors (Gedit, VS Code), LibreOffice, and the Files (Nautilus) manager—the standard shortcuts work as expected:

  • Copy: Ctrl + C
  • Cut: Ctrl + X
  • Paste: Ctrl + V

The Files App (Nautilus) Specifics

When managing files and folders in the file manager:

  • Select files/folders.
  • Press Ctrl + C (Copy) or Ctrl + X (Cut).
  • manage to the destination folder.
  • Press Ctrl + V (Paste).

Pro Tip: You can also use the context menu. Right-click the selected items, choose Copy or Cut, handle to the destination, right-click an empty space, and select Paste Not complicated — just consistent..

Drag and Drop

Click and hold a file or selected text, drag it to the destination folder or text field, and release The details matter here..

  • Default behavior (same drive): Move (Cut/Paste).
  • Hold Ctrl while dragging: Force Copy (shows a small + icon).
  • Hold Alt while dragging: Often prompts a menu asking for Copy, Move, or Link.

The Middle-Click Paste (Primary Selection)

This is the most distinct Ubuntu feature Nothing fancy..

  1. Highlight any text anywhere (browser, terminal, PDF, text editor) using the left mouse button.
  2. Move your cursor to the target input field (terminal prompt, search bar, compose window).
  3. Click the scroll wheel (Middle Mouse Button). The highlighted text appears instantly. If your mouse lacks a middle button, pressing the left and right buttons simultaneously often emulates a middle click, or you can configure "Middle Click Emulation" in Settings > Mouse & Touchpad.

Terminal (Command Line) Mastery

The terminal is where copy-paste confusion peaks for beginners. Because Ctrl + C is the universal "Interrupt/SIGINT" signal (stopping a running command), it cannot be used for Copy. The terminal reserves Ctrl + C for killing processes.

Standard Terminal Shortcuts (GNOME Terminal / Terminal App)

Ubuntu’s default terminal uses shifted shortcuts to avoid conflict with shell signals:

  • Copy: Ctrl + Shift + C
  • Paste: Ctrl + Shift + V
  • Copy (Alternative): Ctrl + Insert
  • Paste (Alternative): Shift + Insert

These shortcuts interact with the Clipboard Selection (the explicit buffer), allowing you to move text between the terminal and GUI apps (like a browser or IDE) smoothly And that's really what it comes down to..

Right-Click Context Menu

Right-clicking inside the terminal window opens a context menu with Copy, Paste, Select All, and Copy Output of Last Command (a handy feature in newer GNOME Terminal versions).

The "Highlight + Middle Click" Workflow in Terminal

This is the fastest way to move text into the terminal or between terminal windows:

  1. Highlight a command or output text in the terminal (or a browser).
  2. Click the middle mouse button at the terminal prompt. The text is pasted immediately from the Primary Selection. This does not require Ctrl + Shift + V.

Copying Output from Previous Commands

If you need to copy the output of a command you just ran:

  1. Highlight the specific lines of output with your mouse.
  2. Press Ctrl + Shift + C (or Middle Click elsewhere to paste). Advanced Tip: In GNOME Terminal, right-click the prompt line of the previous command and select Copy Output to grab the full stdout/stderr instantly without highlighting.

Remote Sessions: SSH, Vim, and Tmux

Copy-paste behavior changes when you leave the local desktop environment.

SSH Sessions

When connected via SSH (ssh user@host), you are inside a remote shell. The terminal shortcuts (Ctrl + Shift + C/V) still work because they are handled by your local terminal emulator (GNOME Terminal, Terminator, Kitty, etc.), not the remote server. Highlighting text in the SSH window copies to your local Primary Selection; Middle-clicking pastes from your local buffer into the remote stdin.

Vim / Neovim

Vim has its own internal registers ("clipboards").

  • System Clipboard Integration: If Vim was compiled with +clipboard support (standard on Ubuntu vim-gtk3 or neovim packages), you can access the system Clipboard Selection via the "+ register and the Primary Selection via the "* register.
  • Copy (Yank) to System Clipboard: Visually select text (v), then press "+y.
  • Paste from System Clipboard: In Normal mode, press "+p.
  • Configuration: Add set clipboard=unnamedplus to your .vimrc or init.vim to make Vim's default yank/paste (y/p) use the system clipboard automatically.

Tmux

Tmux manages its own paste buffer.

  • Copy Mode: Press Ctrl + b then [. figure out with arrows/vi keys. Press Space to start selection, Enter to copy to Tmux buffer.
  • Paste: Press Ctrl + b then ].
  • System Clipboard Sync: Requires configuration in .tmux.conf (using `

set-option -g set-clipboard on in .tmux.conf, or by binding copy-mode keys to pipe through xclip (X11) or wl-copy (Wayland).

bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection clipboard"

This sends Tmux selections directly to the system CLIPBOARD selection, making them available with Ctrl + Shift + `

V` in other applications.

Wayland Considerations On Wayland-based desktops (GNOME on Wayland, Sway, etc.), xclip does not work because there is no X11 server. Use wl-copy and wl-paste instead:

bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "wl-copy"

Similarly, Vim/Neovim on Wayland may require wl-clipboard support or the appropriate clipboard provider configured through vim-gtk3 or neovim with unnamedplus Took long enough..

Troubleshooting Common Issues

  • Shortcuts do nothing: Ensure your terminal emulator supports Ctrl + Shift + C/V. Some lightweight terminals (e.g., xterm) rely on highlighting and middle-click only.
  • Vim "+y fails: Run :version and confirm +clipboard is present. If not, install vim-gtk3, vim-gnome, or neovim.
  • Tmux paste missing: Confirm set-option -g set-clipboard on is active and that xclip (X11) or wl-copy (Wayland) is installed

Extending Clipboard Workflows Beyond the Terminal

Many modern editors ship with built‑in support for the system Clipboard, but the integration can be uneven on Wayland.

  • Emacs – When Emacs runs on Wayland, enable the xclip‑yank and xclip‑paste commands via M-x general-clipboard-set-clipboard-command and M-x general-clipboard-get-clipboard-command. A typical configuration looks like:

    (setq xclip-command "wl-copy")
    (setq xclip-paste-command "wl-paste")
    

    This makes M-w and M-y operate on the same primary/selection buffers that other applications use.

  • Visual Studio Code – The built‑in terminal respects the desktop’s Clipboard when the terminal.integrated.cursorBlinking and terminal.integrated.sendSelectionToShell options are left at their defaults. On Wayland, install the wl-clipboard extension from the marketplace; it injects wl-copy/wl-paste into the terminal’s command palette, allowing Ctrl + Shift + C/V to work without extra hacks.

  • Other GUI apps – Most GTK‑based programs (including the file manager, text editors, and IDEs) already expose a “Copy” and “Paste” entry that writes to the primary selection on X11 and to the Clipboard on Wayland. When a terminal emulator respects the same protocols, the two worlds stay in sync automatically.

Automating Clipboard Synchronisation

Clipboard contents can be read or written from shell scripts, which is handy for one‑off transfers or for embedding clipboard actions in larger workflows.

  • Reading the Clipboard –

    # X11
    xclip -selection clipboard -o
    
    # Wayland
    wl-paste
    

    The output can be captured, filtered, and fed to other commands (e.g., grep, awk, jq) Practical, not theoretical..

  • Writing to the Clipboard –

    # X11
    echo "my secret" | xclip -selection clipboard
    
    # Wayland
    echo "my secret" | wl-copy
    

    When combined with ssh, you can push a string from a remote host to the local machine:

    ssh user@remote 'cat /etc/hosts' | xclip -selection clipboard
    

    This eliminates the need for manual copy‑paste steps in scripts that generate configuration snippets or one‑time tokens Took long enough..

  • Clipboard‑aware tmux scripts – A small helper function can be added to ~/.tmux.conf to expose a “copy‑to‑clipboard” command that works on both X11 and Wayland:

    bind-key -T prefix C-y run-shell "tmux show-buffer -p | wl-copy"
    

    Press the prefix followed by C-y to copy the current pane’s scrollback to the system Clipboard, where it can be pasted into any other application The details matter here..

Security and Privacy Considerations

The Clipboard is a shared memory region that any process can read, so it is not a secure place to store secrets.

  • Avoid exposing passwords or API keys – Never copy sensitive material into the primary or Clipboard selection unless you are certain the destination application clears the data

immediately after use. Tools like pass or keepassxc-cli can pipe secrets directly to the target command without ever touching the Clipboard Most people skip this — try not to..

  • Clear the Clipboard after sensitive operations – A simple alias or function can wipe the selection once you’re done:

    # X11
    alias clipclear='echo -n | xclip -selection clipboard'
    
    # Wayland
    alias clipclear='wl-copy --clear'
    

    Run clipclear after pasting a token, or wrap it in a wrapper script that auto‑clears after a timeout.

  • Isolate Clipboard access per‑session – On Wayland, each compositor instance maintains its own Clipboard namespace. Running untrusted GUI apps inside a nested Wayland compositor (e.g., cage or gamescope) prevents them from snooping on the host Clipboard. On X11, xclip -selection clipboard -o can be restricted with xauth or by running the app under a dedicated X server (Xephyr, Xvfb).

  • Audit Clipboard managers – Persistent managers (Clipman, Diodon, CopyQ, wl-clipboard-manager) store history on disk. Ensure their storage directories (~/.local/share/…) are encrypted or at least chmod 700, and configure them to ignore selections marked “private” (some managers respect the CLIPBOARD_MANAGER hint).

  • Network‑transparent Clipboard – Tools like ssh -X or waypipe forward Clipboard data over the network. Treat the forwarded Clipboard as you would any other network channel: enable only for trusted hosts, and disable forwarding (ForwardX11 no, waypipe --no-clipboard) when not needed Which is the point..

Putting It All Together

A strong Clipboard workflow on Linux is less about a single magic setting and more about a layered approach:

  1. Choose the right backend – xclip/xsel for X11, wl-clipboard for Wayland.
  2. Run a lightweight manager – Clipman (Wayland) or CopyQ (cross‑platform) for history without bloat.
  3. Configure your terminal – Alacritty, Kitty, WezTerm, or VS Code terminal to read/write the system Clipboard natively.
  4. Bridge tmux – Use tmux-yank or a custom run-shell binding so prefix‑y pushes the tmux buffer to the system Clipboard.
  5. Script defensively – Read with wl-paste/xclip -o, write with wl-copy/xclip -i, and clear immediately after handling secrets.
  6. Harden the environment – Restrict Clipboard managers, isolate untrusted apps, and audit network forwarding.

When each layer respects the same selection protocol (PRIMARY for quick middle‑click, CLIPBOARD for explicit Ctrl + C/V), the friction between terminal, GUI, and remote sessions disappears. You can yank a JSON snippet from a remote jq pipeline, drop it into a local VS Code window, tweak it, and push it back to the server—all without ever leaving the keyboard.


Bottom line: The Linux Clipboard ecosystem is fragmented only if you treat each tool in isolation. By standardising on wl-clipboard/xclip, adding a modest history manager, and wiring your terminal multiplexer and editors to the same selection buffers, you gain a seamless, scriptable, and reasonably secure copy‑paste experience that works across X11, Wayland, SSH, and containers alike.

New Content

Hot Off the Blog

More of What You Like

In the Same Vein

Thank you for reading about How To Copy And Paste In Ubuntu. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home