Recall & Review
beginner
What does the
cp command do in Linux?The
cp command copies files or directories from one location to another.Click to reveal answer
beginner
How do you copy a file named
file1.txt to file2.txt using cp?Use the command:
cp file1.txt file2.txt. This copies the contents of file1.txt into a new file called file2.txt.Click to reveal answer
beginner
What option do you use with
cp to copy directories recursively?Use the
-r or --recursive option to copy directories and all their contents.Click to reveal answer
intermediate
What does the
-i option do when used with cp?The
-i option asks for confirmation before overwriting an existing file.Click to reveal answer
intermediate
How can you preserve file attributes like timestamps and permissions when copying with
cp?Use the
-p option to preserve the original file's mode, ownership, and timestamps.Click to reveal answer
Which
cp option copies directories and their contents?✗ Incorrect
The
-r option copies directories recursively, including all files inside.What happens if you run
cp file1.txt file2.txt and file2.txt already exists?✗ Incorrect
By default,
cp overwrites the destination file without asking.Which option makes
cp ask before overwriting files?✗ Incorrect
The
-i option stands for interactive mode and asks before overwriting.How do you copy a file and keep its original timestamps and permissions?
✗ Incorrect
The
-p option preserves file attributes like timestamps and permissions.What does the
-v option do when used with cp?✗ Incorrect
The
-v option stands for verbose and shows the copy progress.Explain how to copy a directory and all its contents to a new location using
cp.Think about how to include all files inside the directory.
You got /4 concepts.
Describe how to safely copy a file without accidentally overwriting an existing file.
This option asks you before replacing files.
You got /3 concepts.