In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the rcp command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
Linux common commands rcp commands make file replication between two Linux hosts easier. With proper configuration, copying files between two Linux hosts without entering a password is as simple as local file replication.
Rcp makes file replication between two Linux hosts easier
Syntax rcp (options) (parameters) option-p: retain the attributes of the source file or directory, including owner, group, permissions and time;-r: recursive processing, processing files under the specified directory together with subdirectories;-x: encrypt all information transmitted between two Linux hosts. -D: specifies the port number of the remote server. The home directory of the user with the same name. If no remote user name is given, the current user name is used. If the path on the remote machine contains special shell characters, you need to enclose the backslash\\, double quotation marks "", or single quotation marks''so that all shell metacharacters can be interpreted remotely. To be clear, rcp does not prompt for a password, it performs the copy through the rsh command.
Directory each file or directory parameter can be either a remote file name or a local file name. The remote file name has the following form rname@rhost:path, where rname is the remote user name, rhost is the remote computer name, and path is the path to the file.
Parameter source file: specifies the source file to copy. There can be multiple source files.
Conditions for the use of instance rcp command
If there is a / etc/hosts file on the system, the system administrator should ensure that the file contains entries for the remote host with which to communicate. Configuration process:
Effective only for root users
1. Establish the rhosts file under the root directory of both root users, and add the hostname of both sides. Before that, you should add each other's ip and hostname 2 to each other's / etc/hosts file and start the rsh service. Redhat is not started by default. Method: execute the ntsysv command, select with the space key before the rsh option, and determine the exit. Then execute service xinetd restart. 3. Go to the / etc/pam.d/ directory and comment out the auth required / lib/security/pam_securetty.so line in the rsh file with "#". (you can log in with root only if you comment out this line.)
Copy the test1 from the current directory to a remote system named webserver1:
Rcp test1 webserver1:/home/root/test3 in this case, test1 is copied to the remote subdirectory test3, and the name is still test1. If only the remote hostname is provided, rcp will copy the test1 to the remote home directory, with the name still test1.
You can also include the file name in the destination directory. For example, copy the file to a system named webserver1:
Rcp test1 webserver1:/home/root/test3 in this case, copy the test1 to the remote directory root and name it test3.
Copy files from a remote system: to copy files from a remote system to a local directory:
Rcp remote_hostname:remote_file local_fileEnter copies the test2 from the remote system webserver1 to the current directory:
Rcp webserver1:/home/root/test2 .Enter. Is an abbreviated form of "current directory". In this case, the test2 in the remote directory is copied to the current directory and the name is still test2.
If you want to copy the file with a new name, provide the target file name. If you want to copy test2 to another directory on your local system, use the following absolute or relative pathnames:
Rcp webserver1:/home/root/test2 otherdir/ Enter or, if you want to copy the file to a different directory with a different file name:
Rcp webserver1:/home/root/test2 otherdir/otherfile Enter copies the directory to the remote system:
To copy the local directory and its files and subdirectories to the remote system, use both the rcp and-r (recursive) options.
Rcp-r local_dir remote_hostname:remote_dir Enter if there is no local_dir in the current directory, you need to provide a relative pathname (starting from the current directory) or an absolute pathname (starting from the / top-level directory) in addition to the local directory name. In addition, if there is no remote_dir under the home directory, remote_dir will need a relative path (starting from the autonomous directory) or an absolute path (starting from /).
To fully copy the subdirectory named work to the directory named products under the home directory on the webserver1 remote computer, type:
Rcp-r work webserver1:/home/root/products Enter this command creates a directory called work and its entire contents under webserver1:/home/root/products (assuming / home/root/products already exists in webserver1).
This example assumes that the user is in a local directory that contains work. Otherwise, you must provide a relative or absolute path to the directory, such as / home/root/work.
Copy the directory from the remote system:
To copy a remote directory and all its files and subdirectories to a local directory, use the rcp and-r (recursive) options in the following syntax.
"rcp-r remote_hostname:remote_dir local_dir Enter to copy a remote directory named work to the current directory, type:"
Rcp-r webserver1:/home/root/work. Enter. Represents the current directory. The work directory will be created under this directory.
Thank you for reading this article carefully. I hope the article "how to use rcp commands in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.