đŸ•ˇī¸ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 32 (from laksa097)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

â„šī¸ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
2 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.freecodecamp.org/news/the-linux-cp-command-how-to-copy-files-in-linux/
Last Crawled2026-04-06 14:31:20 (2 days ago)
First Indexed2022-06-06 18:50:25 (3 years ago)
HTTP Status Code200
Meta TitleThe Linux cp Command – How to Copy Files in Linux
Meta DescriptionBy Dillion Megida There are a couple different ways to copy and paste content when you're working on your computer. If you spend more time in the user interface of your device, you'll probably use your mouse to do this. You can copy files by right-cl...
Meta Canonicalnull
Boilerpipe Text
By Dillion Megida There are a couple different ways to copy and paste content when you're working on your computer. If you spend more time in the user interface of your device, you'll probably use your mouse to do this. You can copy files by right-clicking on the file and selecting "Copy", then going to a different directory and selecting "Paste". For my terminal friends, you can also perform file copy-paste operations without leaving the terminal. In a Linux-based terminal, you do this using the cp command. In this article, I'll explain what the cp command is and show you how to copy and paste files and directories in Linux using the terminal. What is the cp command? You use the cp command for copying files from one location to another. This command can also copy directories (folders). The syntax of this command is: cp [ .. .file/directory-sources ] [ destination ] [file/directory-sources] specifies the sources of the files or directories you want to copy. And the [destination] argument specifies the location you want to copy the file to. To understand the rest of this article, I will use this folder structure example. Let's say a directory called DirectoryA has two directories in it: DirectoryA_1 and DirectoryA_2 . These subdirectories have many files and sub directories in them. I'll also assume you're currently in the DirectoryA location in the terminal, so if you aren't, make sure you are: cd DirectoryA If you want to copy a file, say README.txt from DirectoryA_1 to DirectoryA_2 , you will use the cp command like this: cp ./DirectoryA_1/README.txt ./DirectoryA_2 # ./DirectoryA_1/README.txt is the source file # ./DirectoryA_2 is the destination If you want to copy more than a file from DirectoryA_1 to DirectoryA_2 , you will use the cp command like this: cp ./DirectoryA_1/README.txt ./DirectoryA_1/ANOTHER_FILE.txt ./DirectoryA_2 As you can see, you will put all the source files first, and the last argument will be the destination. How to copy directories with the cp command By default, the cp command works with files. So if you attempt to copy a directory like this: cp ./DirectoryA_1/Folder/ ./DirectoryA_2 You will get an error stating: ./DirectoryA_1/Folder/ is a directory To copy directories, you have to pass the -r flag. This flag informs the cp command to recursively copy a directory and its contents (which could be files or other sub directories). So for the previous command, you can add the flag before the directory sources like this: cp -r ./DirectoryA_1/Folder/ ./DirectoryA_2 This command will recursively copy the Folder directory in ./DirectoryA_1/ as well as all files and directories in the Folder directory. How to copy files that match a glob pattern A glob pattern is similar to Regex, which allows you to match multiple files with names that match a specific pattern. Learn more about the difference here: Regex vs Glob patterns . For example, if you want to copy all files in DirectoryA_1 with the .txt extension, you can execute this command: cp ./DirectoryA_1/*.txt ./DirectoryA_2 ./DirectoryA_1/*.txt matches files with the .txt extension in their names, and the cp command can copy all those files to the destination. You can check out the glob documentation to learn more about globbing patterns and characters you can use. Now you know how to copy files (and directories) right from the command line. Thanks for reading! Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Markdown
[![freeCodeCamp.org](https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg)](https://www.freecodecamp.org/news/) Menu Menu - [Forum](https://forum.freecodecamp.org/) - [Curriculum](https://www.freecodecamp.org/learn) [Donate](https://www.freecodecamp.org/donate/) [Learn to code — free 3,000-hour curriculum](https://www.freecodecamp.org/) June 6, 2022 / [\#Linux](https://www.freecodecamp.org/news/tag/linux/) # The Linux cp Command – How to Copy Files in Linux ![The Linux cp Command – How to Copy Files in Linux](https://www.freecodecamp.org/news/content/images/size/w2000/2022/06/linux-cp-command.png) By Dillion Megida There are a couple different ways to copy and paste content when you're working on your computer. If you spend more time in the user interface of your device, you'll probably use your mouse to do this. You can copy files by right-clicking on the file and selecting "Copy", then going to a different directory and selecting "Paste". For my terminal friends, you can also perform file copy-paste operations without leaving the terminal. In a Linux-based terminal, you do this using the `cp` command. In this article, I'll explain what the `cp` command is and show you how to copy and paste files and directories in Linux using the terminal. ## What is the `cp` command? You use the `cp` command for copying files from one location to another. This command can also copy directories (folders). The syntax of this command is: ``` cp [...file/directory-sources] [destination] ``` `[file/directory-sources]` specifies the sources of the files or directories you want to copy. And the `[destination]` argument specifies the location you want to copy the file to. To understand the rest of this article, I will use this folder structure example. Let's say a directory called **DirectoryA** has two directories in it: **DirectoryA\_1** and **DirectoryA\_2**. These subdirectories have many files and sub directories in them. I'll also assume you're currently in the **DirectoryA** location in the terminal, so if you aren't, make sure you are: ``` cd DirectoryA ``` ## How to copy files with the `cp` command If you want to copy a file, say **README.txt** from **DirectoryA\_1** to **DirectoryA\_2**, you will use the `cp` command like this: ``` cp ./DirectoryA_1/README.txt ./DirectoryA_2 # ./DirectoryA_1/README.txt is the source file # ./DirectoryA_2 is the destination ``` If you want to copy more than a file from **DirectoryA\_1** to **DirectoryA\_2**, you will use the `cp` command like this: ``` cp ./DirectoryA_1/README.txt ./DirectoryA_1/ANOTHER_FILE.txt ./DirectoryA_2 ``` As you can see, you will put all the source files first, and the last argument will be the destination. ## How to copy directories with the `cp` command By default, the `cp` command works with files. So if you attempt to copy a directory like this: ``` cp ./DirectoryA_1/Folder/ ./DirectoryA_2 ``` You will get an error stating: **./DirectoryA\_1/Folder/ is a directory** To copy directories, you have to pass the `-r` flag. This flag informs the `cp` command to recursively copy a directory and its contents (which could be files or other sub directories). So for the previous command, you can add the flag before the directory sources like this: ``` cp -r ./DirectoryA_1/Folder/ ./DirectoryA_2 ``` This command will recursively copy the **Folder** directory in **./DirectoryA\_1/** as well as all files and directories in the **Folder** directory. ## How to copy files that match a glob pattern A glob pattern is similar to Regex, which allows you to match multiple files with names that match a specific pattern. Learn more about the difference here: [Regex vs Glob patterns](https://dillionmegida.com/p/regex-vs-glob-patterns/). For example, if you want to copy all files in **DirectoryA\_1** with the **.txt** extension, you can execute this command: ``` cp ./DirectoryA_1/*.txt ./DirectoryA_2 ``` `./DirectoryA_1/*.txt` matches files with the `.txt` extension in their names, and the `cp` command can copy all those files to the destination. You can check out the [glob documentation](https://linux.die.net/man/7/glob) to learn more about globbing patterns and characters you can use. Now you know how to copy files (and directories) right from the command line. Thanks for reading\! *** If you read this far, thank the author to show them you care. Say Thanks Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. [Get started](https://www.freecodecamp.org/learn) ADVERTISEMENT freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546) Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public. Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff. You can [make a tax-deductible donation here](https://www.freecodecamp.org/donate/). ## Trending Books and Handbooks - [REST APIs](https://www.freecodecamp.org/news/build-consume-and-document-a-rest-api/) - [Clean Code](https://www.freecodecamp.org/news/how-to-write-clean-code/) - [TypeScript](https://www.freecodecamp.org/news/learn-typescript-with-react-handbook/) - [JavaScript](https://www.freecodecamp.org/news/learn-javascript-for-beginners/) - [AI Chatbots](https://www.freecodecamp.org/news/how-to-build-an-ai-chatbot-with-redis-python-and-gpt/) - [Command Line](https://www.freecodecamp.org/news/command-line-for-beginners/) - [GraphQL APIs](https://www.freecodecamp.org/news/building-consuming-and-documenting-a-graphql-api/) - [CSS Transforms](https://www.freecodecamp.org/news/complete-guide-to-css-transform-functions-and-properties/) - [Access Control](https://www.freecodecamp.org/news/how-to-build-scalable-access-control-for-your-web-app/) - [REST API Design](https://www.freecodecamp.org/news/rest-api-design-best-practices-build-a-rest-api/) - [PHP](https://www.freecodecamp.org/news/the-php-handbook/) - [Java](https://www.freecodecamp.org/news/the-java-handbook/) - [Linux](https://www.freecodecamp.org/news/learn-linux-for-beginners-book-basic-to-advanced/) - [React](https://www.freecodecamp.org/news/react-for-beginners-handbook/) - [CI/CD](https://www.freecodecamp.org/news/learn-continuous-integration-delivery-and-deployment/) - [Docker](https://www.freecodecamp.org/news/the-docker-handbook/) - [Golang](https://www.freecodecamp.org/news/learn-golang-handbook/) - [Python](https://www.freecodecamp.org/news/the-python-handbook/) - [Node.js](https://www.freecodecamp.org/news/get-started-with-nodejs/) - [Todo APIs](https://www.freecodecamp.org/news/build-crud-operations-with-dotnet-core-handbook/) - [JavaScript Classes](https://www.freecodecamp.org/news/how-to-use-classes-in-javascript-handbook/) - [Front-End Libraries](https://www.freecodecamp.org/news/front-end-javascript-development-react-angular-vue-compared/) - [Express and Node.js](https://www.freecodecamp.org/news/the-express-handbook/) - [Python Code Examples](https://www.freecodecamp.org/news/python-code-examples-sample-script-coding-tutorial-for-beginners/) - [Clustering in Python](https://www.freecodecamp.org/news/clustering-in-python-a-machine-learning-handbook/) - [Software Architecture](https://www.freecodecamp.org/news/an-introduction-to-software-architecture-patterns/) - [Programming Fundamentals](https://www.freecodecamp.org/news/what-is-programming-tutorial-for-beginners/) - [Coding Career Preparation](https://www.freecodecamp.org/news/learn-to-code-book/) - [Full-Stack Developer Guide](https://www.freecodecamp.org/news/become-a-full-stack-developer-and-get-a-job/) - [Python for JavaScript Devs](https://www.freecodecamp.org/news/learn-python-for-javascript-developers-handbook/) ## Mobile App - [![Download on the App Store](https://cdn.freecodecamp.org/platform/universal/apple-store-badge.svg)](https://apps.apple.com/us/app/freecodecamp/id6446908151?itsct=apps_box_link&itscg=30200) - [![Get it on Google Play](https://cdn.freecodecamp.org/platform/universal/google-play-badge.svg)](https://play.google.com/store/apps/details?id=org.freecodecamp) ## Our Charity [Publication powered by Hashnode](https://hashnode.com/) [About](https://www.freecodecamp.org/news/about/) [Alumni Network](https://www.linkedin.com/school/free-code-camp/people/) [Open Source](https://github.com/freeCodeCamp/) [Shop](https://www.freecodecamp.org/news/shop/) [Support](https://www.freecodecamp.org/news/support/) [Sponsors](https://www.freecodecamp.org/news/sponsors/) [Academic Honesty](https://www.freecodecamp.org/news/academic-honesty-policy/) [Code of Conduct](https://www.freecodecamp.org/news/code-of-conduct/) [Privacy Policy](https://www.freecodecamp.org/news/privacy-policy/) [Terms of Service](https://www.freecodecamp.org/news/terms-of-service/) [Copyright Policy](https://www.freecodecamp.org/news/copyright-policy/)
Readable Markdown
![The Linux cp Command – How to Copy Files in Linux](https://www.freecodecamp.org/news/content/images/size/w2000/2022/06/linux-cp-command.png) By Dillion Megida There are a couple different ways to copy and paste content when you're working on your computer. If you spend more time in the user interface of your device, you'll probably use your mouse to do this. You can copy files by right-clicking on the file and selecting "Copy", then going to a different directory and selecting "Paste". For my terminal friends, you can also perform file copy-paste operations without leaving the terminal. In a Linux-based terminal, you do this using the `cp` command. In this article, I'll explain what the `cp` command is and show you how to copy and paste files and directories in Linux using the terminal. ## What is the `cp` command? You use the `cp` command for copying files from one location to another. This command can also copy directories (folders). The syntax of this command is: ``` cp [...file/directory-sources] [destination] ``` `[file/directory-sources]` specifies the sources of the files or directories you want to copy. And the `[destination]` argument specifies the location you want to copy the file to. To understand the rest of this article, I will use this folder structure example. Let's say a directory called **DirectoryA** has two directories in it: **DirectoryA\_1** and **DirectoryA\_2**. These subdirectories have many files and sub directories in them. I'll also assume you're currently in the **DirectoryA** location in the terminal, so if you aren't, make sure you are: ``` cd DirectoryA ``` If you want to copy a file, say **README.txt** from **DirectoryA\_1** to **DirectoryA\_2**, you will use the `cp` command like this: ``` cp ./DirectoryA_1/README.txt ./DirectoryA_2 # ./DirectoryA_1/README.txt is the source file # ./DirectoryA_2 is the destination ``` If you want to copy more than a file from **DirectoryA\_1** to **DirectoryA\_2**, you will use the `cp` command like this: ``` cp ./DirectoryA_1/README.txt ./DirectoryA_1/ANOTHER_FILE.txt ./DirectoryA_2 ``` As you can see, you will put all the source files first, and the last argument will be the destination. ## How to copy directories with the `cp` command By default, the `cp` command works with files. So if you attempt to copy a directory like this: ``` cp ./DirectoryA_1/Folder/ ./DirectoryA_2 ``` You will get an error stating: **./DirectoryA\_1/Folder/ is a directory** To copy directories, you have to pass the `-r` flag. This flag informs the `cp` command to recursively copy a directory and its contents (which could be files or other sub directories). So for the previous command, you can add the flag before the directory sources like this: ``` cp -r ./DirectoryA_1/Folder/ ./DirectoryA_2 ``` This command will recursively copy the **Folder** directory in **./DirectoryA\_1/** as well as all files and directories in the **Folder** directory. ## How to copy files that match a glob pattern A glob pattern is similar to Regex, which allows you to match multiple files with names that match a specific pattern. Learn more about the difference here: [Regex vs Glob patterns](https://dillionmegida.com/p/regex-vs-glob-patterns/). For example, if you want to copy all files in **DirectoryA\_1** with the **.txt** extension, you can execute this command: ``` cp ./DirectoryA_1/*.txt ./DirectoryA_2 ``` `./DirectoryA_1/*.txt` matches files with the `.txt` extension in their names, and the `cp` command can copy all those files to the destination. You can check out the [glob documentation](https://linux.die.net/man/7/glob) to learn more about globbing patterns and characters you can use. Now you know how to copy files (and directories) right from the command line. Thanks for reading\! *** Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. [Get started](https://www.freecodecamp.org/learn)
Shard32 (laksa)
Root Hash13723046482134587832
Unparsed URLorg,freecodecamp!www,/news/the-linux-cp-command-how-to-copy-files-in-linux/ s443