Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the scp command of linux

Shulou Source: shulou.com Published: 2022-06-01 15:26:50 10月02日 Update

This article mainly explains "how to use the scp command of linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the scp command of linux.

Linux's scp command copies files and directories between linux

=

Scp command

=

Scp can copy files between 2 linux hosts

Basic format of the command:

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 first and second specify the user name, and then enter the password after the command is executed. the first one only specifies the remote directory, the file name remains the same, and the second specifies the file name.

The third and fourth do not specify a user name, and you need to enter a user name and password after the command is executed, the third only specifies a remote directory, the file name remains the same, and the fourth specifies a file name.

* example:

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

Scp / home/space/music/1.mp3 root@www.cumt.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 the 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 the password is required after the command is executed.

The second one does not specify a user name. You need to enter a user name and password after the command is executed.

* example:

Scp-r / home/space/music/ root@www.cumt.edu.cn:/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 replication.

=

Copy from remote to local

=

Copy from remote to local, as long as you change the order of the last two parameters of the command copied from local to remote

For example:

Scp root@www.cumt.edu.cn:/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 user name @ IP address: file name 1 remote user name @ IP address: file name 2

[local user name @ IP address:] you don't have to enter, you may need to enter the password corresponding to the remote user name.

Several parameters that may be useful:

-v has the same meaning as-v in most linux commands and is used to show progress. Can be used to view connections, authentication, or configuration errors.

-C enable compression option.

-P Select the port. Note that-p has been used by rcp.

-4 forcibly use IPV4 address.

-6 forcibly use IPV6 address.

At this point, I believe you have a deeper understanding of "how to use the scp command of linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Commands users user names files directories inputs addresses passwords file names parameters formats examples content names learning practical deeper host between interests Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi MariaDB macOS Shulou Technology