Detailed explanation of cp/scp command + scp command of Linux (reproduced)

Name: cp

Access: All users

Usage :

cp [options] source dest

cp [options] source... directory

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

The program-a

will copy the file status, permissions and other information as it is as much as possible.

-r If the source contains a directory name, the files in the directory will be copied to the destination in sequence.

-f If a file with the same file name already exists at the destination, delete it before copying.

Example:

Copy the file aaa (existing) and name it bbb:

cp aaa bbb

Copy all C language programs to the Finished subdirectory:

cp *.c Finished

command: scp

copy files between different Linux are commonly used in 3 Method:

The first is ftp, that is, one of the Linux installations ftp Server, so that the other can use the ftp client program to copy files.

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

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

    scp is a file copy with Security, based on ssh login. It is more convenient to operate. For example, to copy the current file to another remote host, the following command can be used.

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

Then you will be prompted to enter the login password of the root user of the other 172.19.2.75 host, and then start copying.

    If you want to do it in reverse, copying files from the remote host to the current system is also very simple.

Linux cp/scp command + scp command detailed explanation (transfer) .gz

linux's scp command can copy files and directories between linux;

=================
scp command
============== ====
scp can copy files between 2 linux hosts;

basic command format:
       scp [optional parameters] file_source file_target

======
copy from local to remote
======
* copy files:
        * command Format:
                scp local_file remote_username@remote_ip:remote_folder
                or
                scp local_file remote_username@remote_ip:remote_file
                or
                scp local_file remote_ip:remote_folder
                or
                scp local_file remote_ip:remote_file

                The 1st and 2nd ones specify the user name. After the command is executed, you need to enter the password again. The first one only specifies the remote directory, and the file name is different. Change, the second specifies the file name;
                the third and fourth do not specify the user name, the user name and password need to be entered after the command is executed, the third only specifies the remote directory, the file name remains unchanged, and the fourth specifies the file name;
        * Example:
                scp /home/space/music/1.mp3 [email protected]:/home/root/others/music
                scp /home/space/music/1.mp3 [email protected] .edu.cn:/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 remote_username@remote_ip:remote_folder
                or
                scp -r local_folder remote_ip:remote_folder

                The first one specifies the user name, and you need to enter the password after the command is executed;
                the second one does not specify the user name, and you need to enter the user name and password after the command is executed;
        * 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 will change the local music directory Copy to the remote others directory, that is, there is a remote ../others/music/ directory after copying


======
Copy from remote to local
======
To copy from remote to local, just reverse the order of the last two parameters of the command to copy from local 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 username@IP address: filename1 remote user Name@IP address: file name 2

[local user name@IP address:] can be omitted, you may need to enter the password corresponding to the remote user name.

Several parameters that may be useful:

-v and -v in most linux commands mean Same, used to show progress. Can be used to view connection, authentication, or configuration errors.

-C enables compression options.

-P selects port. Note that -p is already used by rcp

.

Use IPV6 address.



Note two points:
1. If the remote server firewall has special restrictions, scp will use a special port. The specific port depends on the situation. The command format is as follows:
#scp -p 4588 [email protected] :/usr/local/sin.sh /home/administrator
2. When using scp, pay attention to whether the user used has the permission to read the corresponding files of the remote server.

A programmer who can't type code

This article quoted from:
http://www.cnblogs.com/hitwtx/archive/2011/11/16/2251254.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326598168&siteId=291194637
Recommended