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
.
directory1
contains a file named my_file.txt
The below image shows how we can copy my_file.txt
from directory1
to directory2
.
Next, I am showing how you can specify the path to copy a file from your working directory.
Hope this article will help you to understand the Linux copy command. Thanks for reading.