In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly analyzes the relevant knowledge of what is the command of copying files in Linux system, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what is the command to copy files in the Linux system".
Usage 1 destinationFile $cp sourceFile destinationFile when both the sourceFile and destinationFile parameters are file names, the cp command copies the contents of the source file to a new file named after destinatioFile. The contents of the source file remain unchanged. The new file has a new creation time and modification time.
Command line:
Results:
Note: when destinationFile already exists, the general Linux system will remind the user whether to overwrite the original file. Usage 2: copy the file with the same name $cp / home/sheepcore/Documents/newfile / home/sheepcore/Downloads (absolute file path must be given) command line:
If you only need to copy to the current directory, you can simplify it as follows:
$cp / home/sheepcore/Documents/newfile. Indicates the current file directory, i.e. / home/sheepcore/Documents)
Usage 3VR $cp-p destinationFile newDestnFile uses the-p (preserve mode) parameter to retain the access time and modification time of the source file for the target file!
Command line:
Use 4vl $cp-R sourceDir destinationDir to recursively copy the entire source directory to the destination directory using the-R (recursive) parameter. Its function is extremely powerful!
Command line:
Usage 5: use the cp instruction to create hard and soft links to a file
$cp-l srcFile linkedFile (hard link-l for link)
$cp-s srcFile linkedFile (soft link-s for soft)
Command line:
The hard link creates a separate file that contains the information and location of the source file. Therefore, referencing a hard-linked file is equivalent to referencing the source file.
As shown in the command line above, create a hard-linked file fileLink for the file file, and you can see from the file list that the index node numbers of file and fileLink are exactly the same, indicating that they are actually the same file. Notice carefully that the number 2 after-rw-r-r- indicates the count of links in this file, indicating that there are currently two links in two files.
Of course, it is not allowed to create hard links between files on different storage media. At this point, you can use one of the following methods to create soft links through-s.
The following is the result:
Notice that in the figure, I marked out several differences:
\ 1. The soft link file has a new index node number
\ 2. The file size of soft link files is significantly smaller than that of source files and hard link files.
\ 3. The number of links in the soft link file is shown as 1, while the source file and hard link file are shown as 2?
Then, let me briefly explain these differences. When creating a soft-linked file, the Linux system treats it as a separate file, so it has a unique index number. The reason why the file is smaller is that the linked file only needs to store the information of the source file, such as access time, file size, address, etc., but not the contents of the source file, that is, the data inside. Because the soft link essentially creates a new file, the link count is 1.
Add: you can use the wildcard character * to batch copy files with the same name prefix to a directory!
$cp-f file* destinationDir-f (force) forcibly overwrites existing target files without prompting!
Command line instance:
Tip: relative paths can be used. (current directory) or.. (parent directory of the current directory) $cp-v. / file*.. / destinationDir command line instance:
On "what is the command for Linux system to copy files" is introduced here, more related content can be searched for previous articles, hope to help you answer questions, please support the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.