Copy and paste text between Vm and host

Source: Internet
Author: User
Tags ssh server

We often encounter errors when executing commands such as compiling or running certain programs in Linux Shell on the Virtual Machine Platform, at this time, I want to copy the wrong code or running condition to the Windows platform and paste it into the online forum for help. But copying shell characters directly under a virtual machine cannot be pasted in a Windows environment. How can we copy and paste the characters in a Linux Shell in a Windows environment, we can solve this problem in three ways.

I. Using SSH
This method requires installing the SSH service on Linux in the virtual machine. It is installed by default. To ensure that the sshd service is enabled, the RedHat platform can run the command RedHat-config-services in shell to check whether the sshd service is enabled in the service configuration window that appears, if sshd is not enabled, check the sshd option and restart the task. If the SSH service is not installed in Linux, download the SSH package and reinstall it.
After the SSH service is running, download and install the SSH client program on the Windows platform, run the SSH client, click quick connect, enter the IP address and User Name of the Virtual Machine Linux, and the default port is 22. After prompting you to enter the password, you can log on to the Linux SSH server. After logon, You can execute Linux commands in the shell environment of the SSH client, just as it is executed locally in Linux, which is very convenient. In the SSH shell environment, you can copy characters in the current shell and paste them in windows. In this way, you can save some error messages after executing the command to a text file or paste them to the Forum for help. Note that the IP addresses of Linux and local windows under the virtual machine are in the same network segment; otherwise, the SSH client program cannot connect to the Linux SSH server. In Linux, the command for setting the nic ip address is ifconfig, for example, ifconfig.
Eth0 192.168.0.2, eth0 is the virtual machine default Nic name.

Ii. Use VMware Tools
After VMware Tools is installed on a virtual machine, if you are running VMware Tools, you can copy and paste text between the application of the virtual machine and the host, or between the two virtual machines.
To copy and paste:
1. Make sure that you have installed and started VMware Tools on your VM.
2. Select the project to be copied in the source window using the methods supported by the operating system in the source window.
3. Change the cursor and keyboard to control the project to the target window, and paste the project as supported by the operating system in the target window.
You can only copy and paste text, not images or other projects.
(For details about how to use VMware Tools, refer)

Iii. Linux Command redirection
Redirects the information returned by running the Linux Command to a text file, such as./gdbserver 192.168.0.1: 1234 Hello> &info.txt, "&" indicates that all information is output. After that, copy the info.txt file containing the output information to Windows to view it. There are many ways to copy files, such as SSD, FTP, and shared file functions provided by virtual machines. Here is a simple example. Ssh itself comes with a file transfer function. In Windows, after the SSH client connects to the Virtual Machine server, click New file transfer window on the toolbar, you can open a file transfer interface similar to CuteFTP, where you can easily upload and download files.

Three solutions are proposed here. If you frequently use SSH, the first method is undoubtedly the simplest and most convenient. In addition, ssh itself is very powerful and provides shell terminal, file transmission, and other functions for easy operation, high security. If you do not use SSH, the second method is more convenient. You only need to run vmware-Toolbox before copying texts between the host and the virtual machine, after VMware Tools is installed on a virtual machine, run the vmware-Toolbox command in shell. The third method is more suitable for processing large amounts of data. If you want to copy and paste a large amount of text, you can use the file for transmission.

 

Note: when using the second method, enter vmware-Toolbox on the terminal. command, if GTK-warning **: failed to load module "libgnomebreakpad appears. so ": libgnomebreakpad. so: cannot open shared object file: no such file or directory error. This error occurs when the library file is registered. For more information, see the next article.Lost "libgnomebreakpad. So"
= Failed to load module "libgnomebreakpad. So"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.