Linux command: copy files between hosts scp

Source: Internet
Author: User
Tags scp command
The above command copies the local music directory to the remote others directory, that is, there is a remote ../others/================
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 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 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 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 Directory:
* Command format:
Scp-r local_folder remote_username @ remote_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/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 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 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/
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.