Để sao chép tất cả nội dung có trong thư mục /dir vào thư mục /tmp, thi hành lệnh:
Trả lời:
Đáp án đúng: D
This question tests knowledge of the cp (copy) command in Linux and its commonly used options when copying directories.
Analysis of the answers:
- A.
cp -r /dir/* /tmp: This command uses the-r(recursive) option to recursively copy the directories and files inside/dirto the/tmpdirectory. The*character is a wildcard, meaning "all files and subdirectories directly" in/dir. This is a correct way to copy the contents of a directory. - B.
cp -a /dir/* /tmp: The-a(archive) option is a more powerful option. It is equivalent to using the-dR -Poptions. It preserves most of the original properties of the files and directories, such as permissions, timestamps, and symbolic links. When copying important data, this is a good choice. - C.
cp --parents /dir/* /tmp: The--parentsoption creates the parent directories according to the source path in the destination directory. For example, if you have/dir/subdir/file.txt, usingcp --parents /dir/subdir/file.txt /tmpwill create/tmp/dir/subdir/file.txt. In this case, it still copies the content, but it will create the corresponding directory structure inside /tmp. - D. All of the above: Since all three answers A, B, and C perform the copying of content from /dir to /tmp in different ways, this answer is correct.





