Use the SCP command to upload and download data from the server

Source: Internet
Author: User
Tags scp command
\ SVN: delete all. SVN files. Find.-Name. svn-type D-exec Rm-fr {}\; detailed explanation of Linux CP/SCP command + SCP command

 

Name: CP

Permission: All Users

Usage:

CP [Options] source dest

CP [Options] source... directory

Note: copy one file to another or copy several files to another directory.

Count

-A tries its best to copy the file status, permissions, and other information as they are.

-R if the source contains the directory name, the files under the directory are also copied to the destination in sequence.

-F if the destination already has an archive with the same file name, delete it before copying.

Example:

Copy the file AAA (already exists) and name it BBB:

CP aaa bbb

Copy all C language programs to the finished subdirectory:

Cp *. c finished

Command: SCP

There are three common methods to copy files between Linux:

The first is FTP, that is, one of the Linux installation FTP server, so that another client program using FTP can be used to copy files.

The second method is to use the samba service, similar to the Windows file copy method, which is simple and convenient.

The third is to use the SCP command to copy files.

SCP is a file copy with security and is used for SSH logon. For example, to copy the current file to another remote host, you can run the following command.

SCP/home/daisy/full.tar.gz [email protected] 172.19.2.75:/home/root

Then, you will be prompted to enter the logon password of the root user of the other 172.19.2.75 host, and copy the password.

If you want to copy files from the remote host to the current system, it is also very easy.

SCP [email protected]/full.tar.gz 172.19.2.75:/home/root/full.tar.gz home/daisy/full.tar.gz

The SCP command of Linux can copy files and directories between Linux;

============================
SCP command
============================
SCP can copy files between two Linux Hosts;

Basic command format:
SCP [optional parameter] file_source file_target

======
Copy from local to remote
======
* Copy a file:
* Command format:
SCP local_file [email protected] _ IP: remote_folder
Or
SCP local_file [email protected] _ IP: remote_file
Or
SCP local_file remote_ip: remote_folder
Or
SCP local_file remote_ip: remote_file

The user name is specified for the 1st and 2nd commands. After the command is executed, you need to enter the password. Only the remote directory is specified for the 1st command. The file name remains the same, and the file name is specified for the 1st command;
No user name is specified for the 3 and 4 commands. After the command is executed, enter the user name and password. Only the remote directory is specified for the 3rd commands. The file name remains the same and the file name is specified for the 4th commands;
* Example:
SCP/home/SPACE/music/1.mp3 [email protected]:/home/root/Others/music
SCP/home/SPACE/music/1.mp3 [email protected]:/home/root/Others/music/001.mp3
SCP/home/SPACE/music/1.mp3 www.cumt.edu.cn:/home/root/Others/music
SCP/home/SPACE/music/1.mp3 www.cumt.edu.cn:/home/root/Others/music/001.mp3

* Copy directory:
* Command format:
SCP-r local_folder [email protected] _ IP: remote_folder
Or
SCP-r local_folder remote_ip: remote_folder

1st user names are specified, and the password needs to be entered after the command is executed;
2nd user names are not specified. After the command is executed, enter the user name and password;
* Example:
SCP-r/home/SPACE/music/[email protected]:/home/root/Others/
SCP-r/home/SPACE/music/www.cumt.edu.cn:/home/root/Others/

The above Command copies the local music directory to the remote others directory, that is, there is a remote ../Others/music/directory after the copy.


======
Copy from remote to local
======
From remote to local, you only need to replace the last two parameters of the local command to remote;

For example:
SCP [email protected]:/home/root/Others/music/home/SPACE/music/1.mp3
SCP-r www.cumt.edu.cn:/home/root/Others/home/SPACE/music/

The simplest application is as follows:

SCP Local User Name @ IP Address: file name 1 remote user name @ IP Address: file name 2

[Local username @ IP Address:] You may not need to enter the password corresponding to the remote username.

Several useful parameters:

-V is the same as-V in most Linux commands. It is used to display the progress. It can be used to view the connection, authentication, or configuration error.

-C enable compression options.

-P: select the port. Note that-P has been used by RCP.

-4 Use the IPv4 address forcibly.

-6 Use IPv6 addresses forcibly.


Use the SCP command to upload and download data from the server

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.