Sobes.tech
Junior — Middle

How can a file be copied in the Linux operating system?

sobes.tech AI

Answer from AI

In Linux, the command cp is used to copy files.

Example of copying a file:

cp /path/to/source/file /path/to/destination

For example, to copy document.txt from the current directory to /home/user/backup:

cp document.txt /home/user/backup/

To copy a directory with its contents, use the -r (recursive) option:

cp -r /path/to/directory /path/to/destination

Other useful options:

  • -v — verbose, shows files being copied.
  • -i — interactive, prompts before overwriting.

Example with options:

cp -ri source_dir/ target_dir/
How can a file be copied in the Linux operating… - sobes.tech