• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Copy Files From One Folder To Another in Linux Ubuntu

How To Copy Files From One Folder To Another in Linux Ubuntu

By Sourabh / June 26, 2023 Category: How To, Ubuntu

How do you copy files from one folder to another Linux recursively? Do you wish to learn how to copy all the files from one folder to another in Linux?

Here is the command to copy file in Linux with new name or copy file in Linux in same directory.

How to Copy Files in Ubuntu Command Line

cp command is used to copy files and directories. The ‘cp’ copies files (or, optionally, directories). You can either copy one file to another, or copy arbitrarily many files to a destination directory.

The command syntax is:

cp [path/to/file] [destination]

Note that if two file names are given, ‘cp’ copies the first file to the second.

How To Copy Multiple Files In Ubuntu

To copy multiple files in Ubuntu, just append multiple files with the cp command separating them with space.

So the syntax to copy file1, file2 and file3 all at once will be:

cp file1 file2 file3 Destination/

How To Copy Multiple Directories

Just like files, you can copy folders or directories using the cp command in Linux.

By default, ‘cp’ does not copy directories. However, the ‘-R’, ‘-a’, and ‘-r’ options cause ‘cp’ to copy recursively by descending into source directories and copying files to corresponding destination directories. (see below for command syntax)

Just use the cp command in the same way as we do it for a file.

cp -r source_dir1 source_dir2 source_dir3 target_dir

How To Copy Files From One Directory To Another In Terminal

To copy files from one directory to another in terminal use the -R option with the cp command:

cp -R Target_Directory/ Destination/

Note that you can use the argument ‘–copy-contents’ when copying recursively. It is used to copy the contents of any special files as if they were regular files.

If you want to rename and copy files in Ubuntu, just use the new file name with the destination while using the cp command:

cp [path/to/file] [destination/New_File_name]

If you want to copy attributes only, use the command argument ‘–attributes-only’. This is used to copy only the specified attributes of the source file to the destination.

You must note that if the destination already exists, do not alter its contents.

Similarly -b or –backup argument can be used to make a backup of each file that would otherwise be overwritten or removed.

For more controls, use ‘-i’ or ‘–interactive’ command options to ask whether to overwrite an existing destination file.

Primary Sidebar

Latest Posts

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap