- Буфер обмена в Linux (копирование и вставка)
- Буфер копирования
- Буфер выбора (первичный буфер)
- Копирование и вставка в терминале
- How to Copy and Paste Text, Files and Folders in Linux Terminal
- Copy and Paste Text
- Copy and Paste a Single File
- Copy and Paste a Folder and Its Contents
- Copy and Paste Multiple Files
- Copy and Paste All Files of the Same Type
- Move a File or Folder
- How to Copy Paste in Linux Terminal [For Absolute Beginners]
- How to copy paste text and commands in the Linux terminal
- Method 1: Using keyboard shortcuts for copy pasting in the terminal
- Method 2: Using right click context menu for copy pasting in the terminal
- Method 3: Using mouse to copy paste in Linux terminal
- There is no universal key shortcuts for copy paste in the Linux terminal. Here’s why!
- Why Linux terminals do not use the ‘universal’ Ctrl+C and Ctrl+V for
- Copy and paste in the terminal — Debian
- digitard
- digitard
- digitard
Буфер обмена в Linux (копирование и вставка)
Хочу рассказать о некоторых особенностях буфера обмена в Linux. О буфере копирования и про буфер выбора (первичный буфер), а также про копирование и вставку текста в терминале.
Буфер копирования
Стандартно для копирования и вставки объектов в Linux используются сочетания клавиш Ctrl+C и Ctrl+V. При копировании текст (или любой другой объект) в таком случае попадает в обычный буфер копирования. Затем вы можете вставить этот текст в другом месте.
Буфер выбора (первичный буфер)
В Linux существует еще буфер выбора или первичный буфер. Текст, который вы выделяете в любой программе, автоматически попадает в буфер обмена! Это удобно, выделил текст, открыл другое окно и вставил этот кусок текста. Есть некоторые исключения, но они незначительны. Например, у меня в Ubuntu это не работает, если программа использует JVM (Java Virtual Machine).
Кстати, именно этим объясняется следующие поведение. Вы выделили текст в программе, затем открыли другую программу и выделили какой-нибудь текст в ней. После этого, выделение текста в первой программе автоматически снимется, а текст который вы выделили последним, попадет в буфер выбора.
Копирование и вставка в терминале
В терминале для копирования и вставки не работают стандартные сочетания Ctrl+V, Ctrl+C. Это связано с тем, что исторически Ctrl+C это сочетание клавиш для прерывания текущего процесса. Поэтому, для копирования и вставки при работе в терминале используются сочетания Ctrl+Insert и Shift+Insert соответственно. В Gnome терминале и, наверное, во многих других также работают сочетания Shift+Ctrl+C и Shift+Ctrl+V. Они же указаны в главном меню программы в разделе Правка.
Также в терминале работают сочетания клавиш Ctrl+U, чтобы вырезать текст; и Ctrl+Y для вставки текста. Сочетание Ctrl+U работает особенным образом — в буфер копируется вся текущая строка, введенная в терминале, независимо от того, выбрали вы какой-нибудь текст мышкой или нет, а сама строка пропадает с экрана.
Источник
How to Copy and Paste Text, Files and Folders in Linux Terminal
Copying and pasting is one of the most used actions on a computer. While it is easy to do so with the Ctrl + C and Ctrl + V keyboard shortcuts, on the Linux terminal it is not so straightforward. You have several options to get the job done. Here is how you can copy and paste text, files and directories in Linux terminal.
Also read: How to Easily Rename Files in Linux
Copy and Paste Text
If you just want to copy a piece of text in the terminal, all you need to do is highlight it with your mouse, then press Ctrl + Shift + C to copy.
To paste it where the cursor is, use the keyboard shortcut Ctrl + Shift + V .
The Paste shortcut also applies when you copy a section of text from a Word document (or any other application) and want to paste it in the terminal. For example, you can copy a command from a web page in your browser and use the Ctrl + Shift + V shortcut to paste it in the terminal.
Copy and Paste a Single File
Any time you want to copy a file or folder in the Linux command line, the above keyboard shortcut won’t work. You have to use the cp command. cp is shorthand for copy. The syntax is simple, too. Use cp followed by the file you want to copy and the destination where you want it moved.
That, of course, assumes that your file is in the same directory you’re working out of. You can specify both.
You also have the option of renaming your file while copying it. Specify the new name in the destination.
Copy and Paste a Folder and Its Contents
In order to copy a folder and its contents, you’re going to need to tell the cp command to copy recursively. That’s simple enough with the -r flag.
All the rest of your syntax is exactly the same. The -r flag serves to tell cp that it’s working with a directory and should copy its contents.
If you want the paste action to overwrite existing files, you can add the -f flag:
Also read: How to Compress Files with zstd Utility in Linux
Copy and Paste Multiple Files
You can also copy multiple files. The Linux command line lets you target multiple items at once with brackets <> . You can use them to list the names of each file to be copied separated by commas.
All three files of differing file types will be copied to the Documents directory.
Copy and Paste All Files of the Same Type
If you have a ton of files of the same type to copy, you can use the wildcard character * . The asterisk/wildcard tells the Linux command line to accept absolutely anything in that place. So, if you tell Linux to copy *.jpg , it’ll copy all JPG files, regardless of the name or whatever comes before the .jpg part.
If you want to use multiple file types, say JPG and PNG, you can use the brackets from before.
Move a File or Folder
If you came here looking to move a file from one place to another without making a duplicate, you can do that easily too, but moving a file requires the mv command. The syntax is very similar to cp.
Similarly, you can also rename it.
There is one major difference, though. You don’t need the -r flag to move a whole folder.
That’s all there is to it. You’re ready to start copying and moving your files from the command line. You can see that the command line way can be very efficient in some situations.
Want more pointers on the Linux command line? Here’s how to check sudo history or find out what the chmod 777 command does to your file permission.
Image credit: Copy – Paste by DepositPhotos
Источник
How to Copy Paste in Linux Terminal [For Absolute Beginners]
Last updated October 29, 2020 By Abhishek Prakash 27 Comments
I have been using Linux for a decade now and this is why sometimes I take things for granted.
Copy pasting in the Linux terminal is one of such things.
I thought everyone already knew this until one of the It’s FOSS readers asked me this question. I gave the following suggestion to the Ubuntu user:
Use Ctrl+Insert or Ctrl+Shift+C for copying and Shift+Insert or Ctrl+Shift+V for pasting text in the terminal in Ubuntu. Right click and selecting the copy/paste option from the context menu is also an option.
I thought of elaborating on this topic specially when there is no single universal way of copy and paste in the Linux terminal.
How to copy paste text and commands in the Linux terminal
There are several ways to do this.
Method 1: Using keyboard shortcuts for copy pasting in the terminal
On Ubuntu and many other Linux distributions, you can use Ctrl+Insert or Ctrl+shift+C for copying text and Shift+Insert or Ctrl+shift+V for pasting text in the terminal.
The copy pasting also works for the external sources. If you copy a command example from It’s FOSS website (using the generic Ctrl+C keys), you can paste this command into the terminal using the Ctrl+Shift+V into the terminal.
Similarly, you can use Ctrl+shift+C to copy text from the terminal and then use it to paste in a text editor or web browser using the regular Ctrl+V shortcut.
Basically, when you are interacting with the Linux terminal, you use the Ctrl+Shift+C/V for copy-pasting.
Method 2: Using right click context menu for copy pasting in the terminal
Another way of copying and pasting in the terminal is by using the right click context menu.
Select the text in the terminal, right click and select Copy. Similarly, to paste the selected text, right click and select Paste.
Method 3: Using mouse to copy paste in Linux terminal
Another way to copy paste in Linux terminal is by using only the mouse.
You can select the text you want to copy and then press the middle mouse button (scrolling wheel) to paste the copied text.
Please keep in mind that these methods may not work in all the Linux distributions for a specific reason that I explain in the next section.
There is no universal key shortcuts for copy paste in the Linux terminal. Here’s why!
The keybindings for copy-pasting are dependent on the terminal emulator (commonly known as terminal) you are using.
If you didn’t know that already terminal is just an application and you can install other terminals like Guake or Terminator.
Different terminal applications may have their own keybindings for copying and pasting like Alt+C/V or Ctrl+Alt+C/V.
Most Linux terminals use the Ctrl+Shift+C/V keys but if it doesn’t work for you, you may try other key combinations or configure the keys from the preferences of the terminal emulator.
Quick word about Putty
If you use Putty on Linux or Windows, it uses an entire different keybindings. In Putty, selecting a text automatically copies it and you can paste it using right click.
Why Linux terminals do not use the ‘universal’ Ctrl+C and Ctrl+V for
No Linux terminal will give you Ctrl+C for copying the text. This is because by default Ctrl+C keybinding is used for sending an interrupt signal to the command running in foreground. This usually stops the running command.
This behavior has been existing long before Ctrl+C and Ctrl+V started being used for copy-pasting text.
Since the Ctrl+C keys are ‘reserved’ for stopping a command, it cannot be used for copying.
Used Ctrl+S and hanged the terminal?
Most of us use Ctrl+S keys to save changes made to text, images etc. This key is almost universal for saving same as Ctrl+C is for copying.
However, if you enter Ctrl+S in Linux terminal, it will freeze the terminal. No need to close the terminal and start it again. You can use Ctrl+Q to unfreeze the terminal.
Ctrl+S and Ctrl+Q are shortcut keys for flow control.
I know this is elementary for the Sherlock Holmes of the Linux world but it could still be useful to the Watsons.
New or not, you may always use shortcuts in Linux terminal to make your life easier.
Like what you read? Please share it with others.
Источник
Copy and paste in the terminal — Debian
digitard
Active Member
digitard
Active Member
1) Create a new empty document in the desktop of Debian.
2) Copy and paste commands from browser or wherever you find them on your empty document.
3) highlight the text you want on the document (just select it and do nothing)
4) put the mouse point on the xterm and click the middle button (roller)
EDIT
TL;DR
First attempt to use Linux and you find a guy willing to help you »You have problem with Linux? no problem just put this command on the terminal: [3 lines command]». Then you open the terminal and you try to copy and paste . NOP.
I don’t need fancy environments and tick boxes, I just don’t want to put an unbelievable and unjustifiable amount of effort in order to even try something, paste the dam thing. Unbelievable.
The most insane are the solutions that they suggest for »copy — paste in terminal» in forums and tutorials. Find file with some name at some place that not even exist and edit it with some way that not mentioned at all, then add a line in an unspecified place and you done. Meanwhile you have to put some 3 lines commands in the terminal to follow their instructions xD
Well-Known Member
You can skip the «create new empty document» step. Highlight text (like a terminal command) in your web browser and use CRTL-C to copy the text. Open your terminal and use CTRL-SHIFT-V to paste the text. Or using the middle-click button should work too.
To copy text FROM the terminal, hightlight the text you want and use CTRL-SHIFT-C .
The terminal cannot use CTRL-C to copy because it is used to stop a running process in the terminal. For example, run the command top to see a live running assessment of what is using your computer memory. Use CTRL-C to stop this process.
CTRL-C and CTRL-V usually work to copy/paste in Linux the same as in Windows, so it works in your web browser. But the terminal is an exception.
digitard
Active Member
You can skip the «create new empty document» step. Highlight text (like a terminal command) in your web browser and use CRTL-C to copy the text. Open your terminal and use CTRL-SHIFT-V to paste the text. Or using the middle-click button should work too.
To copy text FROM the terminal, hightlight the text you want and use CTRL-SHIFT-C .
The terminal cannot use CTRL-C to copy because it is used to stop a running process in the terminal. For example, run the command top to see a live running assessment of what is using your computer memory. Use CTRL-C to stop this process.
CTRL-C and CTRL-V usually work to copy/paste in Linux the same as in Windows, so it works in your web browser. But the terminal is an exception.
In Debian and specifically in xterm none of the key combinations work because you can’t paste in xterm from clipboard, it has to be from the primal buffer which is an other memory place. In Debian you cannot paste the content of the primal buffer because perhaps it is constantly overwritten when you use the browser or for some other reason it’s usually gibberish or empty.
So for Debian users it is what I say above, no key combination works (with laptops it’s even hell to use the insert key, do not bother at all). And if you want to pick up text from terminal to use it in forums etc you highlight the text on xterm, paste it on you document with middle click and from there you do what ever you want with it. Those instructions should be in your face as soon as your first boot.
Источник