main logo

How to Copy Files and Directories in CentOS?

Share
Try Medha Cloud for free
Click below to sign up and get $200 of credit to try our products over 60 days!
Contents
Rakshitha
Rakshitha is a cloud hosting expert who helps businesses get the most out of their cloud services. She has experience setting up and managing cloud environments to improve performance and scalability. With her cloud certification, Rakshithe provides clear advice on how to use cloud solutions effectively for better business results.

In this post we will see how to copy Files using terminal commands in CentOS. CentOS is a Community Enterprise operating system which mainly focuses on the server. It is a part of Linux Operating System Distribution and it is free to use. First open the terminal.

Total Time Needed: 30 Minutes

Required Tools:

CentOS

Steps to Copy Files and Directories in CentOS

Step 1 : Copy Files
To copy files use the command cp source destination. For example to copy a file 1.txt to directory dir4. Type the command cp 1.txt dir4 and press enter.

Step 2 : Copy Multiple Files:
To copy multiple files, use the same command as above with multiple sources. For example, to copy 2.txt, 3.txt, 4.txt to dir4. Use the paths, type the command cp /root/2.txt /root/3.txt /root/4.txt /root/dir4 and press enter.

Step 3 : Copy Files to the Current Directory
To copy files to the current directory, use the command “cp source .” . For example, to copy file2 to the current directory type “ cp /root/file2 . “

Step 4 : Copy Directories
To copy Directories, use the command cp –r . For example, to copy dir5 to dirc type the command
cp –r dir5 dirc and press enter.

Step 5: Copy Directory to Current Directory
To copy directory to the current directory without using the destination, use the command “ cp-r source .“
For example, to copy directory dirA to current directory type, the command cp –r /root/dirA . And press enter.

Conclusion:
Hope you understand how to copy file and directories in CentOS. If you have any doubts, please contact Medha Hosting. Our LInux experts are available 24/7 to assist you.
Read Here: How To Archive And Extract Files In CentOS?

Related Articles

medhacloud logo
USA:
Medha Cloud Solutions LLC
30 N Gould St Ste R, Sheridan, WY 82801,
Phone: +1 646 775 2855

India:
Medha Hosting Private Limited
#74, 7 Th Cross, Krishna Garden InCity Layout. Chikka Kammanahalli, Banneraghatta Road, Bangalore 560083
Phone:+91 93536 44646

E-Mail: support@medhahosting.com
©Medha Cloud 2024. All rights reserved.