0
0
Linux CLIscripting~5 mins

cp (copy files and directories) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A-v
B-p
C-i
D-r
What happens if you run cp file1.txt file2.txt and file2.txt already exists?
AIt deletes <code>file1.txt</code>
BIt merges the two files
CIt overwrites <code>file2.txt</code> without asking
DIt creates a backup automatically
Which option makes cp ask before overwriting files?
A-v
B-i
C-r
D-p
How do you copy a file and keep its original timestamps and permissions?
Acp -p
Bcp -i
Ccp -r
Dcp -v
What does the -v option do when used with cp?
AShows each file being copied
BPreserves file permissions
CCopies files faster
DCopies directories recursively
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.