In the copying of Linux files, the copying speed is very slow when there are many files. So, is there any way to speed up the copying of files? The following small series will introduce you to the method of speeding up the copying of Linux files. When
The first method
First of all, whether local or remote, you need to move or copy files and not much more, with the cp command mv command and inefficient You can use the tar tool to package/compress the content to be copied/moved, then copy/move it, and then unpack/unzip it.
In addition, it is also a very important skill, that is, you do not have to copy, unpack/decompress after tar is packaged/compressed, and you can perform package copy/solution by packing/compressing the other side through the pipeline. compression.
For example, the tar command can be combined with the nc command to quickly transfer files and directories between two machines:
B machine:
The code is as follows:
"/p" "p" nc -l 5555 |
Tar -C /tmp/test/-xf - "/p" "p"
A machine:
The code is as follows:
"/p" "p" tar Cf - /tmp/test/|
Nc B‘IP 5555 "/p" "p"
The above steps copy the contents of the A machine /tmp/test/to the directory corresponding to the B machine, where tar cf - /tmp/test/|
Nc B & rsquo;IP 5555 package content side by pipe and nc command to be transferred to the B machine by the corresponding IP address and 5555 port, nc -l 5555 |
Tar -C /tmp/test/-xf - Listens to the 555 port of the machine and unpacks the received content to the specified directory (the -C parameter specifies the target directory)
The second method
>
Combine tar with the scp and ssh commands:
After the A machine is packaged, copy it to the B machine and unpack it.
The code is as follows:
"/p "p" tar -cf - /tmp/test |
Ssh B‘IP “cd /tmp; tar -xf -”"/p" "p"
Packing in machine A and copying the packaged file to machine B
The code is as follows:
"/p" "p" tar -cf - /tmp/test |
Ssh B’IP “cd /tmp; cat - 》 test.tar”"/p" "p" tar -cf - /tmp/test |
Scp - "a href=“mailto:B‘USER@B’IP:/tmp”"B‘USER@B’IP:/tmp"/a"/p"p"
The package file of the A machine is copied to the B machine and unpacked.
The code is as follows:
"/p" "p" zcat test.tar |
Ssh B‘IP “cd /tmp; tar -xf -”"/p" "p"
can also be used directly locally:
The code is as follows:
"/p" "p" cd /tmp/test1 "/p" "p" tar -cf -. |
(cd /tmp/test2 ; tar -xvpf -) "/p" "p"
But some people have come to the conclusion that it is faster to use cp directly.
In addition to copying a single file when copying The directory will also be copied, sometimes with the properties of the file/directory. You can use the -R parameter to recursively copy the directory in the cp command, and use the -p parameter to copy the file retention attribute (the default is: mode, ownership, timestamps can also specify the attributes to be reserved by --preserve[=ATTR_LIST] such as: context. Links, xattr, all), use the -d parameter to copy the file to retain the connection. Or simply use the -a parameter (equivalent to using -dR --preserve=all)
If you want to see the progress of copying a large number of small files, you can write a simple little script:
As follows:
"/p" "p" cd /tmp/test "/p" "p" for i in * "/p" "p" do "/p" "p" cp $i target Directory "/p" "p" echo $i is ok. . . "/p" "p" done "/p" "p"
Finally add a trick that is not skill: before using a tool to complete a task, think about whether the tool currently used is the most suitable tool? Is there a better tool or method? If the tool is really suitable for the current task, is there any special technique to improve productivity when using the tool? (Usually, viewing help files can be a surprise.)
The above is the method to speed up the copying speed of the file. If you want to copy more and more files, use the method described above to speed up the copying speed. Try it.
gcc and ifor compiler are more commonly used by developers, before the small series also introduced
The sound menu in Ubuntu system is unique. The sound of all applications can be adj
Most people on Linux use the rpm -i xxxx.rpm command to install the RPM package. In
The DD command under Linux system is one of the commonly used commands, and the DD
Linux tips for using FDisk tools
Ubuntu10.10 configuration R environment method
Linux tips for viewing directory content
What should I do if I get an error when compiling PARSEC 2.1 under Ubuntu?
Steps to install Fluentd on RedHat
Linux system Java is not compatible with Siyuan blackbody solution
How to install rar and unrar commands in Linux
How to improve the speed of Google Chrome running under Linux?
How Linux mounts iso yum source in virtual machine
Linux SecureCRT Chinese garbled how to do?
Linux network management command list
How to customize the History output format for Linux systems
Windows XP effectively reduces startup time
Win10 10074 preview version of the start menu can not open the solution
The audio and video life under Windown 7 The popular online movie 1
Win10 Cortana Xiaona option does not show the reason for the search box phenomenon and the solution
Windows7 system online to get more gadgets graphic tutorial
How to turn on the four channels under Windows 7
Windows7 shared folders can't be accessed by other systems.
Win8 mac virtual machine network connection