Duplicating files or text in Linux can be done through both the terminal and graphical desktop environments. Understanding how to copy paste in linux is essential for anyone moving from Windows or macOS, as the methods differ significantly. This guide covers every practical approach, from basic commands to advanced clipboard tricks.
Linux offers multiple ways to copy and paste, depending on whether you work in the terminal or a GUI. The terminal uses keyboard shortcuts and commands, while desktop environments often mimic Windows behavior. You’ll learn both, plus how to handle files, text, and even remote sessions.
How To Copy Paste In Linux
This section breaks down the core methods for copying and pasting across different Linux environments. Whether you’re a beginner or an experienced user, these steps will save you time.
Copy And Paste In The Terminal
The terminal is where Linux power users spend most of their time. Copying and pasting here works differently than in a word processor.
- Copy text: Highlight the text with your mouse. It’s automatically copied to the clipboard.
- Paste text: Click the middle mouse button (scroll wheel) to paste. Alternatively, press
Ctrl+Shift+V. - Copy commands: Use
Ctrl+Shift+Cto copy selected text in most terminal emulators. - Paste commands: Use
Ctrl+Shift+Vor the middle mouse button.
Note: The standard Ctrl+C and Ctrl+V don’t work in the terminal because Ctrl+C sends an interrupt signal. Always use the Shift key.
Copy And Paste In GUI Applications
Graphical desktop environments like GNOME, KDE, or XFCE follow familiar patterns. You can use mouse actions or keyboard shortcuts.
- Mouse method: Select text, then right-click and choose “Copy” or “Paste.”
- Keyboard method:
Ctrl+Cto copy,Ctrl+Vto paste. This works in text editors, browsers, and file managers. - Clipboard managers: Tools like CopyQ or Parcellite store multiple items for later use.
Most modern Linux distros include clipboard integration, so you can copy from a terminal and paste into a GUI app, and vice versa.
Copying Files And Directories
For file operations, Linux uses commands like cp and rsync. These are more powerful than GUI drag-and-drop.
Using The Cp Command
The cp command copies files and directories. Basic syntax: cp source destination.
- Copy a single file:
cp file1.txt file2.txt - Copy to a directory:
cp file1.txt /home/user/documents/ - Copy a directory recursively:
cp -r folder1 folder2 - Preserve attributes:
cp -p file1.txt file2.txt
Use cp -i to prompt before overwriting files. This prevents accidental data loss.
Using Rsync For Advanced Copying
Rsync is ideal for copying large amounts of data or syncing directories. It only transfers differences.
- Basic copy:
rsync -av source/ destination/ - Copy over SSH:
rsync -avz -e ssh user@remote:/path/ /local/path/ - Dry run:
rsync -av --dry-run source/ destination/
Rsync is faster than cp for repeated copies because it skips unchanged files.
Copying Text Between Terminal And GUI
Sometimes you need to copy output from a terminal command into a document. Here’s how to bridge the gap.
- Redirect output to a file:
command > output.txt - Pipe output to clipboard:
command | xclip -selection clipboard - Paste from clipboard into terminal:
xclip -o -selection clipboard
Install xclip if it’s not present: sudo apt install xclip (Debian/Ubuntu) or sudo dnf install xclip (Fedora).
Using Keyboard Shortcuts Effectively
Mastering shortcuts speeds up your workflow. Here are the most important ones for Linux.
- Ctrl+Shift+C: Copy in terminal
- Ctrl+Shift+V: Paste in terminal
- Ctrl+C: Copy in GUI (or interrupt in terminal)
- Ctrl+V: Paste in GUI
- Middle mouse click: Paste selected text anywhere
- Ctrl+Insert: Copy (alternative in some terminals)
- Shift+Insert: Paste (alternative)
Practice these until they become second nature. They work across most Linux distributions.
Copying In File Managers
File managers like Nautilus (GNOME) or Dolphin (KDE) provide intuitive copy-paste options.
- Copy a file: Right-click the file and select “Copy,” or press
Ctrl+C. - Paste a file: Navigate to the target folder, right-click empty space, and choose “Paste,” or press
Ctrl+V. - Cut a file: Right-click and choose “Cut,” or press
Ctrl+X. - Copy path: Some file managers offer “Copy Path” in the right-click menu.
You can also drag files while holding Ctrl to copy them instead of moving.
Copying And Pasting In Vim
Vim uses a modal system, so copy-paste works differently. Here’s how to manage it.
Basic Vim Copy-Paste
- Copy (yank): In normal mode, press
yyto copy a line, orywto copy a word. - Paste: Press
pto paste after the cursor, orPto paste before. - Copy multiple lines: Use
3yyto copy three lines. - Copy to system clipboard: Use
"+yto yank into the system clipboard.
To paste from system clipboard into Vim, use "+p in normal mode.
Using Vim With Mouse Support
Enable mouse support with :set mouse=a. Then you can select text with the mouse and paste with middle click.
For beginners, consider using vim-gtk or gvim which have better clipboard integration.
Copying In Nano Editor
Nano is simpler than Vim. Copy-paste is more straightforward.
- Copy text: Press
Alt+6after selecting text withCtrl+Shift+Arrow. - Cut text: Press
Ctrl+Kto cut an entire line. - Paste text: Press
Ctrl+Uto paste. - Select text: Use
Ctrl+6to start selection, then move cursor.
Nano also supports mouse clicks if enabled with -m flag.
Copying And Pasting Over SSH
Remote sessions require special handling. Here’s how to copy files and text securely.
Copying Text In SSH Sessions
- Local to remote: Use
Ctrl+Shift+Cin your local terminal, thenCtrl+Shift+Vin the SSH session. - Remote to local: Select text in the SSH terminal, then paste locally with
Ctrl+V. - Clipboard forwarding: Some SSH clients like PuTTY support clipboard sharing.
Copying Files Over SSH
Use scp (secure copy) or rsync over SSH.
- Copy file to remote:
scp file.txt user@remote:/path/ - Copy file from remote:
scp user@remote:/path/file.txt . - Copy directory recursively:
scp -r folder/ user@remote:/path/
For better performance, use rsync -avz -e ssh as shown earlier.
Using Clipboard Tools
Clipboard utilities extend functionality beyond basic copy-paste.
Xclip And Xsel
These command-line tools let you interact with the clipboard.
- Copy output to clipboard:
echo "text" | xclip -selection clipboard - Paste from clipboard:
xclip -o -selection clipboard - Copy to primary selection:
echo "text" | xclip(without -selection)
Xsel works similarly: echo "text" | xsel -b for clipboard, xsel -b to paste.
Clipboard Managers
Install a clipboard manager to store history.
- CopyQ: Advanced manager with search and editing.
- Parcellite: Lightweight and simple.
- Diodon: Integrates with GNOME.
These tools let you paste items you copied hours ago, which is incredibly useful.
Common Mistakes And Troubleshooting
Even experienced users make errors. Here’s how to fix them.
Ctrl+C Doesn’t Copy In Terminal
Remember: Ctrl+C sends SIGINT. Use Ctrl+Shift+C instead. If that doesn’t work, check your terminal emulator settings.
Middle Click Doesn’t Paste
Some applications disable middle-click paste. Try Shift+Insert as an alternative. Also, ensure your mouse driver is working.
Clipboard Not Shared Between Apps
This happens when using Wayland instead of X11. Wayland has stricter clipboard policies. Install wl-clipboard for command-line access: sudo apt install wl-clipboard.
Permission Denied When Copying Files
Use sudo if you need to copy to system directories. For example: sudo cp file.txt /etc/. Be careful with permissions.
Advanced Copy-Paste Techniques
For power users, these methods save even more time.
Using Tmux Copy Mode
Tmux is a terminal multiplexer. Its copy mode lets you navigate and copy text.
- Enter copy mode:
Ctrl+b [ - Navigate with arrow keys or Vim keys.
- Start selection: Press
Space - Copy: Press
Enter - Paste:
Ctrl+b ]
Tmux can also integrate with system clipboard if configured.
Copying With Find And Grep
Combine commands to copy specific files.
- Copy all .txt files:
find . -name "*.txt" -exec cp {} /target/ \; - Copy files containing a word:
grep -l "keyword" *.txt | xargs cp -t /target/
These one-liners are powerful for batch operations.
Copying In Different Desktop Environments
Each DE has slight variations. Here’s a quick overview.
- GNOME: Standard shortcuts work. Use
Ctrl+Shift+Cin terminal. - KDE Plasma: Similar to Windows. Clipboard history is built-in (press
Ctrl+Alt+V). - XFCE: Lightweight. Middle-click paste works well.
- LXQt: Minimal. Use standard shortcuts.
If shortcuts don’t work, check your system settings under “Keyboard” or “Shortcuts.”
Copying And Pasting In WSL
Windows Subsystem for Linux (WSL) integrates with Windows clipboard.
- Copy from WSL to Windows: Select text in WSL terminal, then paste in Windows with
Ctrl+V. - Copy from Windows to WSL: Copy in Windows, then
Ctrl+Shift+Vin WSL terminal. - Command-line clipboard: Use
clip.exein WSL:echo "text" | clip.exe
WSL2 supports full clipboard integration with Windows Terminal.
Frequently Asked Questions
How Do I Copy And Paste In Linux Terminal?
Highlight text to copy, then press Ctrl+Shift+C. To paste, press Ctrl+Shift+V or click the middle mouse button. Avoid using plain Ctrl+C as it sends an interrupt signal.
Why Doesn’t Ctrl+V Work In Linux Terminal?
Because Ctrl+V is reserved for other functions in most terminals. Use Ctrl+Shift+V instead. This is a common confusion for new users.
Can I Copy Files Using The Command Line?
Yes, use the cp command. For example, cp file1.txt file2.txt copies a file. Add -r for directories. For advanced syncing, use rsync.
How Do I Copy Text From Terminal To A GUI App?
Select the text in the terminal, then paste it in the GUI app with Ctrl+V or right-click. For command output, use command | xclip -selection clipboard.
What Is The Difference Between Clipboard And Primary Selection?
Primary selection is text you highlight—it’s pasted with middle click. The clipboard is text you explicitly copy with Ctrl+C—pasted with Ctrl+V. Both exist simultaneously.
Mastering how to copy paste in linux takes practice, but these methods cover every scenario you’ll encounter. Start with terminal shortcuts, then explore file commands and clipboard tools. Over time, you’ll develop a workflow that feels natural.
Remember to check your desktop environment’s settings if shortcuts don’t work. Most issues are easily fixed by enabling clipboard integration or installing missing tools. With these skills, you’ll handle text and files efficiently across all Linux systems.