âšī¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://opensource.com/article/21/8/copy-files-linux-terminal |
| Last Crawled | 2026-04-08 23:31:09 (1 day ago) |
| First Indexed | 2021-08-06 07:07:29 (4 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Copy files in the Linux terminal | Opensource.com |
| Meta Description | To copy a file on a computer with a graphical interface, you usually either drag and drop a file from one window to another window, sometimes using a modifier key. |
| Meta Canonical | null |
| Boilerpipe Text | Use the cp command to copy files in the Linux terminal.
To copy a file on a computer with a graphical interface, you usually either drag and drop a file from one window to another window, sometimes using a modifier key. Alternately, you might prefer to right-click on a file icon, select
Copy
, and then
Paste
the file icon into another window.
To copy a file in a terminal, you use the
cp
command, which works exactly like the
mv
command, except that it duplicates the contents of a file rather than moving them from one location to another.
$ cp example.txt ~/Documents
As with the
mv
command, you can
rename a file while copying it.
$ cp example.txt ~/Documents/file.txt
Be careful when using
cp
, because it does exactly what you tell it to do. By default, it does
not
ask you whether you want to copy one file over another file with the same name. To protect yourself from this, use
cp --interactive
(or
-i
for short),
which runs
cp
in
interactive
mode, meaning that it will ask you whether you're sure you want to overwrite an existing file. You can either confirm or cancel and re-do the
cp
and rename the file to something different so that it doesn't conflict with existing files.
Copy a folder
The
cp
command looks for files, not folders because folders don't really exist (that is, they're not really data, they're just markers for us humans to logically divide our data into different imaginary containers.) To copy a folder, use
cp --recursive
(or
-r
for short)
, which takes the files in the folder
and
recreates their imaginary container.
$ cp -r Documents MyStuff
$ ls
Documents
Downloads
Music
MyStuff
Templates
Pictures
Videos
You may notice that the Linux shell is eerily quiet when it works. This is actually by design. How many times have you set a computer on a task, like copying a thousand files from one drive to another, only to come back 4 hours later to find that it stopped copying after the first file, just to ask you some trivial esoteric question?
Sometimes, however, it's nice to have some feedback from your OS. Usually, the
-v
switch adds "verbosity" to the command:
$ cp -r --verbose Documents Stuff
'Documents/' -> 'Stuff'
'Documents/example.txt' -> 'Stuff/example.txt'
'Documents/file.txt' -> 'Stuff/file.txt'
'Documents/example.png' -> 'Stuff/example.png'
'Documents/picture.png' -> 'Stuff/picture.png'
What to read next
Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time.
Related Content
This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. |
| Markdown | [Skip to main content](https://opensource.com/article/21/8/copy-files-linux-terminal#main-content)
[](https://www.redhat.com/en?intcmp=701600000011l7VAAQ)
## User account menu
- [Log in](https://opensource.com/user/login?current=/article/21/8/copy-files-linux-terminal)
- [RSS](https://opensource.com/feed "RSS")
[](https://opensource.com/) [](https://www.redhat.com/en?intcmp=701600000011l7VAAQ)
## Main navigation
- [Articles](https://opensource.com/)
- [Resources](https://opensource.com/resources)
- [What is open source?](https://opensource.com/resources/what-open-source)
- [The open source way](https://opensource.com/open-source-way)
- [Projects and applications](https://opensource.com/resources/projects-and-applications)
- [Organizations](https://opensource.com/resources/organizations)
- [Open source alternatives](https://opensource.com/alternatives)
- [Alternatives to Acrobat](https://opensource.com/alternatives/adobe-acrobat)
- [Alternatives to AutoCAD](https://opensource.com/alternatives/autocad)
- [Alternatives to Dreamweaver](https://opensource.com/alternatives/dreamweaver)
- [Alternatives to Gmail](https://opensource.com/alternatives/gmail)
- [Alternatives to MATLAB](https://opensource.com/alternatives/matlab)
- [Alternatives to Minecraft](https://opensource.com/alternatives/minecraft)
- [Alternatives to Google Photos](https://opensource.com/alternatives/google-photos)
- [Alternatives to Photoshop](https://opensource.com/life/12/6/design-without-debt-five-tools-for-designers)
- [Alternatives to Skype](https://opensource.com/alternatives/skype)
- [Alternatives to Slack](https://opensource.com/alternatives/slack)
- [Alternatives to Trello](https://opensource.com/alternatives/trello)
- [More...](https://opensource.com/alternatives)
- [Linux](https://opensource.com/resources/linux)
- [Downloads](https://opensource.com/downloads)
- [Frequently Asked Questions](https://opensource.com/faq)
# Copy files in the Linux terminal
Use the cp command to copy files in the Linux terminal.
By
[Seth Kenlon](https://opensource.com/users/seth) (Team, Red Hat)
August 6, 2021 \| [0 Comments](https://opensource.com/article/21/8/copy-files-linux-terminal#comments) \|
%t min read

Image by:
CC BY-SA Seth Kenlon
To copy a file on a computer with a graphical interface, you usually either drag and drop a file from one window to another window, sometimes using a modifier key. Alternately, you might prefer to right-click on a file icon, select **Copy**, and then **Paste** the file icon into another window.
To copy a file in a terminal, you use the **cp** command, which works exactly like the **mv** command, except that it duplicates the contents of a file rather than moving them from one location to another.
```
$ cp example.txt ~/Documents
```
As with the **mv** command, you canrename a file while copying it.
```
$ cp example.txt ~/Documents/file.txt
```
Be careful when using **cp**, because it does exactly what you tell it to do. By default, it does *not* ask you whether you want to copy one file over another file with the same name. To protect yourself from this, use **cp --interactive** (or **\-i** for short), which runs **cp** in *interactive* mode, meaning that it will ask you whether you're sure you want to overwrite an existing file. You can either confirm or cancel and re-do the **cp** and rename the file to something different so that it doesn't conflict with existing files.
## Copy a folder
The **cp** command looks for files, not folders because folders don't really exist (that is, they're not really data, they're just markers for us humans to logically divide our data into different imaginary containers.) To copy a folder, use **cp --recursive** (or **\-r** for short), which takes the files in the folder *and* recreates their imaginary container.
```
$ cp -r Documents MyStuff
$ ls
Documents
Downloads
Music
MyStuff
Templates
Pictures
Videos
```
You may notice that the Linux shell is eerily quiet when it works. This is actually by design. How many times have you set a computer on a task, like copying a thousand files from one drive to another, only to come back 4 hours later to find that it stopped copying after the first file, just to ask you some trivial esoteric question?
Sometimes, however, it's nice to have some feedback from your OS. Usually, the **\-v** switch adds "verbosity" to the command:
```
$ cp -r --verbose Documents Stuff
'Documents/' -> 'Stuff'
'Documents/example.txt' -> 'Stuff/example.txt'
'Documents/file.txt' -> 'Stuff/file.txt'
'Documents/example.png' -> 'Stuff/example.png'
'Documents/picture.png' -> 'Stuff/picture.png'
```
More Linux resources
- [Linux commands cheat sheet](https://developers.redhat.com/cheat-sheets/linux-commands-cheat-sheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [Advanced Linux commands cheat sheet](https://developers.redhat.com/cheat-sheets/advanced-linux-commands/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [Free online course: RHEL Technical Overview](https://www.redhat.com/en/services/training/rh024-red-hat-linux-technical-overview?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [Linux networking cheat sheet](https://opensource.com/downloads/cheat-sheet-networking?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [SELinux cheat sheet](https://opensource.com/downloads/cheat-sheet-selinux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [Linux common commands cheat sheet](https://opensource.com/downloads/linux-common-commands-cheat-sheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [What are Linux containers?](https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
- [Our latest Linux articles](https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent)
What to read next
[](https://opensource.com/article/21/8/move-files-linux)
## [Move files in the Linux terminal](https://opensource.com/article/21/8/move-files-linux)
Use the mv command to move a file from one location to another.
[Seth Kenlon](https://opensource.com/users/seth)
(Team, Red Hat)
August 4, 2021
[](https://opensource.com/article/21/8/rename-file-linux-terminal)
## [Rename a file in the Linux terminal](https://opensource.com/article/21/8/rename-file-linux-terminal)
To rename a file in the terminal, move the file with mv from itself to itself with a new name. Here's an example.
[Seth Kenlon](https://opensource.com/users/seth)
(Team, Red Hat)
August 5, 2021
[](https://opensource.com/article/20/5/linux-desktops)
## [24 Linux desktops you need to try](https://opensource.com/article/20/5/linux-desktops)
Gotta catch them all\!
[Seth Kenlon](https://opensource.com/users/seth)
(Team, Red Hat)
May 19, 2020
Tags
[Linux](https://opensource.com/tags/linux)
[Command line](https://opensource.com/tags/command-line)
[Seth Kenlon](https://opensource.com/users/seth)

Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D\&D nerd. He has worked in the film and computing industry, often at the same time.
[More about me](https://opensource.com/users/seth)
## Comments are closed.
These comments are closed.
## Related Content
[](https://opensource.com/article/23/4/linux-gnome-44-features)
[What's new in GNOME 44?](https://opensource.com/article/23/4/linux-gnome-44-features)
[](https://opensource.com/article/23/4/5-reasons-virtual-machines-still-matter)
[5 reasons virtual machines still matter](https://opensource.com/article/23/4/5-reasons-virtual-machines-still-matter)
[](https://opensource.com/article/23/4/image-editing-linux-python)
[Remove the background from an image with this Linux command](https://opensource.com/article/23/4/image-editing-linux-python)
[](https://creativecommons.org/licenses/by-sa/4.0/)This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.
## About This Site
The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat.
[Opensource.com](https://opensource.com/) aspires to publish all content under a [Creative Commons license](https://creativecommons.org/licenses/) but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. Red Hat and the Red Hat logo are trademarks of Red Hat, LLC, registered in the United States and other countries.
A note on advertising: Opensource.com does not sell advertising on the site or in any of its newsletters.
[](https://opensource.com/)
Copyright Š2021 Red Hat, LLC
## Legal
- [Privacy Policy](https://opensource.com/privacy-policy)
- [Terms of use](https://opensource.com/legal) |
| Readable Markdown | Use the cp command to copy files in the Linux terminal.
To copy a file on a computer with a graphical interface, you usually either drag and drop a file from one window to another window, sometimes using a modifier key. Alternately, you might prefer to right-click on a file icon, select **Copy**, and then **Paste** the file icon into another window.
To copy a file in a terminal, you use the **cp** command, which works exactly like the **mv** command, except that it duplicates the contents of a file rather than moving them from one location to another.
```
$ cp example.txt ~/Documents
```
As with the **mv** command, you canrename a file while copying it.
```
$ cp example.txt ~/Documents/file.txt
```
Be careful when using **cp**, because it does exactly what you tell it to do. By default, it does *not* ask you whether you want to copy one file over another file with the same name. To protect yourself from this, use **cp --interactive** (or **\-i** for short), which runs **cp** in *interactive* mode, meaning that it will ask you whether you're sure you want to overwrite an existing file. You can either confirm or cancel and re-do the **cp** and rename the file to something different so that it doesn't conflict with existing files.
## Copy a folder
The **cp** command looks for files, not folders because folders don't really exist (that is, they're not really data, they're just markers for us humans to logically divide our data into different imaginary containers.) To copy a folder, use **cp --recursive** (or **\-r** for short), which takes the files in the folder *and* recreates their imaginary container.
```
$ cp -r Documents MyStuff
$ ls
Documents
Downloads
Music
MyStuff
Templates
Pictures
Videos
```
You may notice that the Linux shell is eerily quiet when it works. This is actually by design. How many times have you set a computer on a task, like copying a thousand files from one drive to another, only to come back 4 hours later to find that it stopped copying after the first file, just to ask you some trivial esoteric question?
Sometimes, however, it's nice to have some feedback from your OS. Usually, the **\-v** switch adds "verbosity" to the command:
```
$ cp -r --verbose Documents Stuff
'Documents/' -> 'Stuff'
'Documents/example.txt' -> 'Stuff/example.txt'
'Documents/file.txt' -> 'Stuff/file.txt'
'Documents/example.png' -> 'Stuff/example.png'
'Documents/picture.png' -> 'Stuff/picture.png'
```
What to read next

Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D\&D nerd. He has worked in the film and computing industry, often at the same time.
## Related Content
[](https://opensource.com/article/23/4/linux-gnome-44-features)
[](https://opensource.com/article/23/4/5-reasons-virtual-machines-still-matter)
[](https://opensource.com/article/23/4/image-editing-linux-python)
[](https://creativecommons.org/licenses/by-sa/4.0/)This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. |
| Shard | 95 (laksa) |
| Root Hash | 12209221891525358495 |
| Unparsed URL | com,opensource!/article/21/8/copy-files-linux-terminal s443 |