When operating Linux remotely, there are many powerful shell commands that can help us. Copying files and folders is a very powerful function. 1. copy command cp on the same machine. Copy the cpfilename1filename2 file, copy filename1, and save it...
When operating Linux remotely, there are many powerful shell commands that can help us. Copying files and folders is a very powerful function.
1. copy command cp on the same machine. Copy the cp filename1 filename2 file, copy filename1, and name it filename2. Add the parameter-f without any prompt when overwriting the renamed File. For example, cp-f filename1 filename2. Add the parameter-r to the above command www.2cto.com to copy the folder. For example, cp-rf dic1 and dic2.
The command for cp details is as follows: syntax: cp [-abdfilpPrRsuvx] [-S <备份字尾字符串> ] [-V <备份方式> ] [-- Help] [-- spares = <使用时机> ] [-- Version] [source file or directory] [target file or directory] [Target Directory]
Note: The cp command is used to copy files or directories. for example, if two or more files or directories are specified at the same time, and the last destination is an existing directory, then it copies all the previously specified files or directories to this directory. If multiple files or directories are specified at the same time, and the last destination is not an existing Directory, an error message is displayed. Parameter: www.2cto.com-a or -- archive. -B or -- backup is deleted to overwrite the backup before the target file. a backup string is added at the end of the backup file. -D or -- no-dereference when copying a symbolic connection, the target file or directory is also established as a symbolic connection and points to the original file or directory connected to the source file or directory. -F or -- force forcibly copies files or directories, whether or not the target file or directory already exists-I or -- interactive overwrites existing files, ask the user. -L or -- link establishes a hard connection to the source file instead of copying the file. -P or -- preserve retains the attributes of the source file or directory. -P or -- parents retains the path of the source file or directory. -R recursive processing: processes the files in the specified directory along with subdirectories. -R or -- recursive processing: all files in the specified directory are processed together with subdirectories. -S or -- symbolic-link establishes a symbolic connection to the source file instead of copying the file. -S <备份字尾字符串> Or -- suffix = <备份字尾字符串> After you use the "-B" parameter to back up the target file, a backup string is added at the end of the backup file. the default backup string is the symbol "~ ". -U or -- update when this parameter is used, the file will be copied only when the source file is updated later than the target file or the target file with the corresponding names does not exist. -V or -- verbose displays the command execution process. -V <备份方式> Or -- version-control = <备份方式> After you use the "-B" parameter to back up the target file, a backup string will be added at the end of the backup file. this string can be changed not only by the "-S" parameter, when you use the "-V" parameter to specify different backup methods, different backup strings are generated. -X or -- one-file-system: the file system in which the file or directory is copied must be the same as the file system in which the cp command is executed; otherwise, the file system will not be copied. Www.2cto.com -- help online help. -- Sparse = <使用时机> Set the time to save sparse files. -- Version: displays the version information.
2. the usage of the command scp between different machines is similar to that of the cp, but it is just running between different machines. Copy a file to another machine: scp-rf filename1 username @:/usr/local/apache/htdocs/bak the command above indicates to put the filename1 file (or folder) in the current directory) copy the username to the/usr/local/apache/htdocs/bak directory on this machine. By-syc
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.