Linux CP/SCP Command +SCP command detailed

Source: Internet
Author: User
Tags file copy ftp client scp command secure copy ssh port what is scp

linux CP/SCP Command +SCP command detailed

Name: CP

Usage rights: All users

How to use:

CP [Options] Source Dest

CP [options] source ... directory

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

The meter

-A as far as possible file status, permissions and other information are reproduced as original.

-R If the source contains a directory name, the files under the directory are also copied to the destination.

-F If a destination already has a file with the same file name, it should be deleted before copying.

Example:

Copy the file AAA (already present) and name the BBB:

CP AAA BBB

Copy all C-language programs to the finished subdirectory:

CP *.c finished

Command: SCP

There are 3 common ways to copy files between different Linux:

The first is FTP, which is one of the Linux installation FTP Server, so you can use an FTP client program to copy files.

The second method is to use Samba services, similar to the Windows file copy method to operate, relatively simple and convenient.

The third is the use of SCP commands for file replication.

SCP is a file copy with security, SSH-based login. Easy to operate, for example, to copy the current file to a remote other host, you can command the following.

SCP /home/Daisy/full. Tar. GZ [email protected]172.19. 2.75:/Home/root

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

It is also easy to copy files from the remote host to the current system if you want to do this in reverse.

Scp[email protected]/Full.Targz 172.19.2.75:/home/root/full. tar. GZ home/daisy/full. Tar. GZ

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

==================
SCP command
==================
SCP can copy files between 2 Linux hosts;

Command basic format:
SCP [Optional parameters] File_source File_target

======
Copy from local to remote
======
* Copy files:
* 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

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]:/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

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
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, 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 [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 applications are as follows:

SCP Local username @IP address: File name 1 remote user name @IP address: file name 2

[Local User name @IP address:] Can not be entered, you may need to enter the password for the remote user name.

Several parameters that may be useful:

-V is the same as-V in most Linux commands to show progress. Can be used to view connections, certifications, or configuration errors.

-C Enable compression option.

-P Select the port. Note-P has been used by RCP.

-4 forcibly use the IPV4 address.

-6 forcibly use the IPV6 address.

< Span style= "color: #000000;" >< Span style= "color: #000000;" > 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- P 4588 [email protected]:/usr/local/sin.sh/home/administrator
2. Using SCP be aware that the user you are using has permission to read the appropriate files for the remote server. /span>

First, what is SCP?

The SCP is a shorthand for secure copy, a command for remotely copying files under Linux, and a similar command with CP, although the CP is only copied natively and cannot cross the server, and the SCP transfer is encrypted. may have a slight effect on the speed.

Ii. What is the use of SCP?

1, we need to obtain a file on the remote server, the remote server does not configure the FTP server, does not open the Web server, and does not share, unable to obtain the file through the regular way, only through the SCP command can easily achieve the purpose.

2, we need to upload the file on the computer to the remote server, the remote server does not open the FTP server or share, can not be uploaded through the conventional way is, only through the SCP command to easily achieve the purpose.

Iii. methods of use of the SCP

1. Get the files on the remote server

Scp-p 2222 [Email protected]:/root/lnmp0.4.tar.gz/home/lnmp0.4.tar.gz

Upper Port Capital P is the parameter, 2222 means the port after changing the SSH port, if not changed SSH port can not add this parameter. [email protected] means that using the root user to log on to the remote server www.vpser.net,:/root/lnmp0.4.tar.gz represents the file on the remote server, and the last face/home/ Lnmp0.4.tar.gz represents the path and file name that is saved locally.

2. Get the directory on the remote server

Scp-p 2222-r [Email protected]:/root/lnmp0.4//home/lnmp0.4/

Upper Port Capital P is the parameter, 2222 means the port after changing the SSH port, if not changed SSH port can not add this parameter. The-r parameter indicates recursive replication (that is, copying files and directories under the directory); [email protected] means that using the root user to log on to the remote server www.vpser.net,:/root/lnmp0.4/represents the directory on the remote server, and the/home/lnmp0.4/on the last side represents the path saved locally.

3. Upload the local file to the server

Scp-p 2222/home/lnmp0.4.tar.gz [Email protected]:/root/lnmp0.4.tar.gz

Upper Port Capital P is the parameter, 2222 means the port after changing the SSH port, if not changed SSH port can not add this parameter. /home/lnmp0.4.tar.gz represents the path and file name of the file that is ready to be uploaded locally. [email protected] means that using the root user to log on to the remote server www.vpser.net,:/root/lnmp0.4.tar.gz represents the directory and file name saved on the remote server.

4. Upload the local directory to the server

Scp-p 2222-r/home/lnmp0.4/[email protected]:/root/lnmp0.4/

Upper Port Capital P is the parameter, 2222 means the port after changing the SSH port, if not changed SSH port can not add this parameter. The-r parameter indicates a recursive copy (that is, copying files and directories under the directory);/home/lnmp0.4/indicates the directory to be uploaded, [email protected] means to log on to the remote server using the root user www.vpser.net,:/root/ LNMP0.4/represents the directory location that is saved on the remote server.

5. Several parameters that may be useful:

-V is the same as-V in most Linux commands to show progress. Can be used to view connections, certifications, or configuration errors.

-C Enable compression option.

-4 forcibly use the IPV4 address.

< Span style= "color: #000000;" >< Span style= "color: #000000;" >< Span style= "color: #ff0000;" >-6 forcibly uses the IPV6 address.

Linux CP/SCP Command +SCP command detailed

Related Article

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.