The Linux scp command is used to copy files and directories between Linux systems. The following describes how to use the command to copy files and directories from a local computer to a remote computer or from a remote computer to a local computer. Here are examples:
============================
Linux 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/
The simplest application is as follows:
Scp Local User Name @ IP Address: file name 1 remote user name @ IP Address: file name 2
[Local username @ IP Address:] You may not need to enter the password corresponding to the remote username.
Several useful parameters:
-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.
-4 Use the IPV4 address forcibly.
-6 Use IPV6 addresses forcibly.
The Linux scp command can be used to copy Linux Files And Directories.
- Introduction to Linux XFS file system I)
- Linux terminal command 1)
- Decrypts an important Linux system directory 1)
- How to check Linux Security Vulnerabilities
- A Brief Introduction to how to obtain the file path of a Linux Process