Which command is used to copy files in UNIX?
a) cp
b) mv
c) rm
d) copy
Answer:
a) cp
Explanation:
The cp
command in UNIX is used to copy files and directories from one location to another. Its syntax is cp source destination
, where source
is the file to be copied and destination
is the target directory or filename.
This command is useful for duplicating files or creating backups. For example, cp file1 file2
will create a copy of file1
and save it as file2
. The -r
option allows copying directories recursively, which includes all subdirectories and their contents.
Understanding the cp
command is vital for managing files in UNIX. It allows users to keep multiple versions of files or easily transfer files between different directories without losing the original.