Anjan Dutta

Copy files from one directory to another in Linux

Copy files from one directory to another in Linux

To copy files and directories in Linux we use the cp command.

Before running the command, you must know the working directory from where you are running the command. And, the relative path to the target and destination files.

Below is the command to copy files from one directory to another: cp /directory_name/file_name.txt /new_directory_name

Let's take a look at the below example:

I have created 2 directories, directory1 and directory2. directory structure

directory1 contains a file named my_file.txt file in directory1

The below image shows how we can copy my_file.txt from directory1 to directory2. copy file from outside directory

Next, I am showing how you can specify the path to copy a file from your working directory. copy file from within directory

Hope this article will help you to understand the Linux copy command. Thanks for reading.