• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Linux-Ubuntu | cp/scp -- copy files/directories
  1. Notes
  2. Examples
  3. Command Help (man cp)

  1. Notes
  2. Examples
    • Copying file:

      • Create a new copy of file1 and rename it to file2 (see bellow the options -i and -n to check if the destination file already exists):
      • Copy file1 from folder1 to folder2 (it's recommended to use a trailing forward slash to be explicit about the destination directory).

      • Copy file1 (renaming it to file2) from folder1 to folder2:
      • Copy all files (excluding subdirectories and files starting with a period (.)) in folder1 to folder2:
        It may complain that there are subdirectories in folder2 "cp: omitting directory ...".

      • Copy all files starting with a period (.) (excluding subdirectories) in folder1 to folder2:
        It may complain that there are subdirectories in folder2 "cp: omitting directory ...".

    • Copying directory:

      • Copy the directory folder1 in folder2:
      • Copy the content (files and subdirectories) of the directory folder1 to folder2:
      • Copy the content (files and subdirectories excluding files starting with a period (.)) of the directory folder1 to folder2:
    • Secure-copying file/directory:

      • Copy a remote file to a local directory:
      • Copy a remote directory to a local directory:
      • Copy a local file to a remote directory:
      • Copy a local directory to a remote directory:
  3. Command Help (man cp)
    The following options can be used:
© 2025  mtitek