Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of copying Files under linux

Shulou Source: shulou.com Published: 2022-06-02 00:50:38 09月28日 Update

Editor to share with you the method of copying files under linux, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The method of copying files under linux: you can use the cp command to copy files, such as [cp cangls / tmp/], which means to copy cangls files to the tmp directory. The cp command is mainly used to copy files and directories, as well as entire directories.

Cp command, mainly used to copy files and directories, at the same time, with some options, you can also copy the entire directory, and compare the old and new files to upgrade and other functions.

The basic format of the cp command is as follows:

[root@localhost ~] # cp [option] Source file destination file

Options:

For example:

The cp command can copy both files and directories. Let's first look at how to copy files, such as:

[root@localhost ~] # touch cangls# set up the source file [root@localhost ~] # cp cangls / tmp/# copy the source file without changing its name to the / tmp/ directory. If you need to change its name to copy, the command is as follows: [root@localhost ~] # cp cangls / tmp/bols# renamed copy

If a file with the same name already exists in the copied destination, you will be prompted whether to overwrite it, because the cp command executes the alias of "cp-I" by default, for example:

[root@localhost ~] # cp cangls / tmp/cp: whether to overwrite "/ tmp/cangls"? there is a file with the same name in the target location of y #, so you will be prompted whether to overwrite it.

Let's take a look at how to copy a directory, but you only need to use the "- r" option to copy a directory, for example:

[root@localhost ~] # mkdir movie# set up a test directory [root@localhost ~] # cp-r / root/movie/ / tmp/# directory original name copy all the contents of the above methods for copying files under linux, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File directory command method source file destination location content at the same time article prompt next not much alias function original name just mostly new and old more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Docker Shulou Information Shulou Technology