Copy file/folder Using cp Command in Linux

Windows Articles

Ubuntu Rolling Release? It is possible with Rolling Rhino

Throughout the Linux community, there are always expectations about when Ubuntu decides to have a Rolling Release. This, at least, since the...

How to recover files deleted with Windows File Recovery

Hello! Deleting files by accident is one of the biggest fears of users. Indeed, unintentionally deleting documents, music or photos can be...

How to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10?

This is a short post in which I will show you how to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10...

Linuxfx is a Windows 10 clone based on Ubuntu.

Hi! Most Windows users are afraid to switch to Linux for various reasons. However, the biggest one is the difference in the...

How to install OpenMeetings on Ubuntu 20.04 / 18.04?

If there is one thing the Internet has completely revolutionized, it is long-distance communications. And with it the business meetings that thanks to many...
Muhammad Nabeel
Muhammad Nabeel
Network and System Administrator

cp (copy) is a command in various Unix and Unix-like operating systems for copying files and directories. The command has three principal modes of operation, copying a file to another file, one or more files to a directory, or for copying entire directories to another directory.

Copy a file

First of all create a file “demo.txt” and a directory “record” using below commands.

touch demo.txt
mkdir record
ls

Now, in the below command we will copy a file “demo.txt” to the “record” directory.

cp demo.txt record

Then, use following command to verify demo.txt file is copied into record directory.

ls record

Copy multiple files

So, in this example we will copy multiple files into a directory. let say we have many files with .txt extension and we want all them to copy in a directory “record” simply use following command.

cp *.txt record
ls record

* means all files matching with .txt extension.

Copy a Directory

Now we will copy a directory into another directory.
Note: Always use -R (capital R) option whenever you copy a directory so that all of data placed in it will also be copied.

SO, We are copying demo directory to the record directory.

ls
cp -R demo record

Then, verify demo directory is copied into record directory.

ls record

You can explore more commands of cp by reading manual using command “man cp

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Ubuntu Rolling Release? It is possible with Rolling Rhino

Throughout the Linux community, there are always expectations about when Ubuntu decides to have a Rolling Release. This, at least, since the...

How to recover files deleted with Windows File Recovery

Hello! Deleting files by accident is one of the biggest fears of users. Indeed, unintentionally deleting documents, music or photos can be...

How to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10?

This is a short post in which I will show you how to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10...

Linuxfx is a Windows 10 clone based on Ubuntu.

Hi! Most Windows users are afraid to switch to Linux for various reasons. However, the biggest one is the difference in the...

How to install OpenMeetings on Ubuntu 20.04 / 18.04?

If there is one thing the Internet has completely revolutionized, it is long-distance communications. And with it the business meetings that thanks to many...