Linux Command-CP and SCP

Source: Internet
Author: User
Tags ftp client scp command

Linux provides two commands for file copy, CP and SCP, but they are slightly different.

  • CP --- mainly used to copy files back and forth between different directories on the same computer
  • SCP --- copy files back and forth between different Linux systems

Usage of CP:
Basic command format:
CP [Options] source DEST --- copy the file from the Source Path to the target path
CP [Options] source... directory --- copy multiple source files to the specified directory (multiple source files are separated by spaces)

Options:
-A same as-DPR copies the source file status, permissions, and other materials as far as possible, and uses recursive copy;
-R indicates recursive copy. If the source contains the directory name, all files in the directory are copied to the destination in sequence;
-F indicates force. If an object with the same file name already exists in the destination, delete the object before copying;
Example:
1. copy the file AAA (already exists) and name it BBB:
CP aaa bbb
2. Copy all C language programs to the finished subdirectory:
Cp *. c finished/

 

Usage of SCP:

 

There are three common methods to copy files between Linux:

The first is FTP, that is, installing FTP server in one of Linux, so that you can use the FTP client program on another machine 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.

Basic command format:
SCP [Options] file_source file_target

 

Options:
-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.

Copy from local to remote
SCP/home/daisy/full.tar.gz root@172.19.2.75:/home/root ), copy the Directory and add the parameter-R.

Copy from remote to localSCP root @/172.19.2.75:/home/root/full.tar.gz/home/daisy/full.tar.gz

    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.