JavaScript is required

Để 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:

A.

cp –r /dir/* /tmp

B.

cp –a /dir/* /tmp

C.

cp --parents /dir/* /tmp

D.

Tất cả đều đúng

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 /dir to the /tmp directory. 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 -P options. 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 --parents option creates the parent directories according to the source path in the destination directory. For example, if you have /dir/subdir/file.txt, using cp --parents /dir/subdir/file.txt /tmp will 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.

Câu hỏi liên quan