

In our case we are moving to the “ /home/itslinux/Desktop” directory as follows: $ cd /home/itslinuxfoss/Desktop Firstly, we should go to the directory where these files are present. The “ cp” command enables the user to perform is to make duplicates of multiple files using just a single command. It is observed that the “newName” file can be located in the directory where it was copied. The following command makes a copy of the file named “ sample” and saves it with a file named “ newName”: $ cp /home/itslinuxfoss/Desktop/sample /home/itslinuxfoss/Desktop/Destination/newName The “ cp” command can also be utilized to make a copy of the file and save it with a different name. Example 2: Copy a Single File and Duplicate it With a Separate Name Let’s navigate to the “ Destination” directory to verify the copy:Īs shown here, the “sample” file is copied from the directory and the duplicate is created inside the “Destination” directory. The successful execution of the command states that the file has been copied successfully. In this example, the “ cp” command is carried out to copy a single file from one location to the other.Ĭheck out the example shown below that copies the file named “ sample” from the “ Desktop” directory to another directory located at “ Desktop”: $ cp /home/itslinuxfoss/Desktop/sample /home/itslinuxfoss/Desktop/Destination Finally, enter the destination path where you want the copy of the file to be created as demonstrated below: $ cp Example 1: Copy a Single File Using “cp” To explain the syntax, “cp” is the keyword used which is followed by the source path of the file that needs to be copied. The “ cp” command is the primary player in duplicating the files from one folder to the same or different. This section will elaborate on all the different ways to copy a file to a different location in a Linux system. Method 1: Using the “cp” Command to Duplicate Files From One Folder to a Different Folder in Linux This article will demonstrate the possible ways to achieve this task in Linux. This process is carried out to make copies of the important files that need backup. In Linux-based OS, there exist several methods through which a copy of any file can be created to a different directory. Creating copies of files is one of the most basic but important actions that exist in file management. File management is a core part of any operating system.
