Hadoop Build Notes: SCP commands for file copy between different Linux hosts under Linux

Source: Internet
Author: User
Tags file copy scp command

<title>There are 3 common ways to copy files between different Linux:</title> There are 3 ways to copy files between different Linux: ①ftp

is one of the Linux installation FTP Server, so you can use another FTP program to copy files.

② Using Samba Services

is similar to the Windows file copy way to operate, relatively simple and convenient.

③ uses the SCP command to copy files.

SCP is a security mechanism for file copy, SSH-based login. Easy to operate, such as the master machine to copy the current file to the slave1 machine, you can command the following.

scp ./test.txt root@slave1:/homw/root

You will then be prompted to enter the login password for the root user of the slave1 machine, and then copy is started.

If you want to reverse the operation, copy the file Test.txt from the slave1 machine to the current system, as follows:

scp root@slave1:/home/root/test.txt ./
SCP can copy files between 2 Linux hosts;

Command basic format:

scp [可选参数] file_source file_target
Copy from local to remote
    • Copying files
      * Command format:
scp local_file remote_username@remote_ip:remote_folder

Or

scp local_file remote_username@remote_ip:remote_file

Or

local_file remote_ip:remote_folder

Or

local_file remote_ip:remote_file

1th, 2 Specify the user name, command execution after the need to enter the password, the 1th only specifies the remote directory, the file name is unchanged, 2nd specified the file name;
3rd, 4 does not specify a user name, command execution after the need to enter a user name and password, the 3rd only specifies the remote directory, the file name is unchanged, 4th specified the file name;
Example

scp/home/space/music/1. mp3[Email protected]. CUMT. edu. CN:/home/root/others/music
scp/home/space/music/1. mp3[Email protected]. CUMT. edu. CN:/home/root/others/music/001. mp3
scp/home/space/music/1. mp3Www. CUMT. edu. CN:/home/root/others/music
scp/home/space/music/1. mp3Www. CUMT. edu. CN:/home/root/others/music/001. mp3
    • To copy a directory:
      * Command format:
scp -r local_folder remote_username@remote_ip:remote_folder

Or

local_folder remote_ip:remote_folder

The 1th one specifies the user name, the command executes after the need to enter the password;
The 2nd does not specify a user name, the command will need to enter the user name and password after execution;
Example

/home/space/music/ root@www.cumt.edu.cn:/home/root/others/
/home/space/music/ www.cumt.edu.cn:/home/root/others/

The above command copies the local music directory to the remote others directory, which is remotely available after replication. /others/music/Directory

Copy from remote to local

From remote copy to local, as long as the copy from the local to the remote command of the following 2 parameter Exchange order;

For example:

scp root@www.cumt.edu.cn:/home/root/others//home/space/music/1.mp3
scp -r www.cumt.edu.cn:/home/root/others//home/space/music/

The simplest applications are as follows:

scp 本地用户名 @IP 地址 : 文件名 1 远程用户名 @IP 地址 : 文件名 2

[ 本地用户名 @IP 地址 :] 可以不输入 , 可能需要输入远程用户名所对应的密码 .

可能有用的几个参数 :

-v 和大多数 linux 命令中的 -v 意思一样 , 用来显示进度 . 可以用来查看连接 , 认证 , 或是配置错误 .

-C 使能压缩选项 .

-P 选择端口 . 注意 -p 已经被 rcp 使用 .

-4 强行使用 IPV4 地址 .

-6 强行使用 IPV6 地址 .

Note two points:
1. If the remote server firewall has special restrictions, the SCP will go to the special port, depending on what port, depending on the situation, the command format is as follows:

#scp -p4588 [email protected].abc.com:/usr/local/sin.sh /home/administrator

2. Use SCP be aware that the user you are using has permission to read the appropriate files for the remote server.

Hadoop Build Notes: SCP commands for file copy between different Linux hosts under Linux

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.