Link copied to clipboard!
Linux & Hosting

How to Copy Files and Directories in CentOS?

Rakshitha
Rakshitha
White-Label Services Specialist
Jul 31, 20202 min read
24
How to Copy Files and Directories in CentOS?

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.
How To Copy Files And Directories In Centos 1
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.
How To Copy Files And Directories In Centos 2
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 . “
How To Copy Files And Directories In Centos 3
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.
How To Copy Files And Directories In Centos 4
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.
How To Copy Files And Directories In Centos 5
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?

Topics

CentOScopying filesVPS hosting
Rakshitha
Written by

Rakshitha

White-Label Services Specialist5+ years

Rakshitha specializes in white-label IT services and Linux server administration. She helps MSPs expand their service offerings through strategic outsourcing partnerships and provides expert guidance on Linux-based infrastructure solutions.

White-Label IT ServicesLinux AdministrationIT Outsourcing
Follow on LinkedIn

Need Expert Help?

Our team of cloud and IT experts is ready to help you solve your toughest challenges. Get personalized assistance today.