ℹ️ 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.1 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://askubuntu.com/questions/195983/how-to-copy-files-via-terminal |
| Last Crawled | 2026-04-11 18:08:27 (3 days ago) |
| First Indexed | 2014-11-18 01:40:22 (11 years ago) |
| HTTP Status Code | 200 |
| Meta Title | command line - How to copy files via terminal? - Ask Ubuntu |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | This question shows research effort; it is useful and clear
189
Save this question.
Show activity on this post.
I have read about copying files with terminal but these examples will help me a lot. So here is what I want to do:
Examples:
I have a file in
/home/levan/kdenlive untitelds.mpg
and I want to copy this file to
/media/sda3/SkyDrive
and do not want to delete any thing in SkyDrive directory.
I have a file in
/media/sda3/SkyDrive untitelds.mpg
and I want to copy this file to
/home/levan/kdenlive
and do not want to delete any thing in kdenlive directory
I want to copy a folder from home directory to
sda3
and do not want to delete any thing on
sda3
directory and opposite
I want to cut a folder/file and copy to other place without deleting files in that directory I cut it into.
Braiam
69.5k
33 gold badges
182 silver badges
281 bronze badges
asked
Oct 3, 2012 at 15:17
1
This answer is useful
245
Save this answer.
Show activity on this post.
1)
By using
-i
for interactive you will be asked if you would like to replace the file:
cp
-i /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
or you can use
-b
to create a backup of your file:
cp
-b /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive
2)
Same as the above:
cp
(-i or -b) /media/sda3/SkyDrive/untitelds.mpg /home/levan/kdenlive
3)
Use
-R
for recursive and
-i
for interactive:
cp
-Ri ~/MyFolder /sda3/
4)
This last one can be done via the
mv
command, move is like cutting:
mv
-i ~/MyFile ~/OtherFolder/MyFile
if you want to move a directory, use:
mv
-Ri ~/MyDirectory ~/OtherDirectory/
answered
Oct 3, 2012 at 15:38
8
This answer is useful
20
Save this answer.
Show activity on this post.
When
~/Dropbox/RECENT/
is your current directory:
cp
input.txt SORT/
And I want to copy
input.txt
with another name in my current directory.
Again with
~/Dropbox/RECENT/
as current directory:
cp
input.txt newname.txt
Existing filenames can be auto-completed using
TAB
.
Long version of the same copy command (when you are not in
~/Dropbox/RECENT/
):
cp
/home/
$USER
/Dropbox/RECENT/input.txt /home/
$USER
/Dropbox/RECENT/SORT/
I put a
/
behind every directory. If
SORT
does NOT exist a
cp
will also create a file named
SORT
making you think something went wrong. Adding the
/
will have
cp
error out and not copy the file.
muru
♦
209k
58 gold badges
520 silver badges
794 bronze badges
answered
Mar 12, 2016 at 13:59
This answer is useful
4
Save this answer.
Show activity on this post.
Use the
cp
command.
Copying a file
something.txt
to file
folder
: use
cp something.txt folder/
Copying a file
something.txt
to the current directory as
something2.txt
: use
cp something.txt something2.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:53 Folder1
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l Folder1/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:53 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:54 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l folder/
total 0
ubuntu@ubuntu-T100TA:~/TestFolder$
cp
something.txt folder/
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l folder/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
cp
something.txt something2.txt
ubuntu@ubuntu-T100TA:~/TestFolder$
ls
-l
total 12
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:55 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something2.txt
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
answered
Mar 12, 2016 at 13:59
This answer is useful
4
Save this answer.
Show activity on this post.
you will better add the option
-a
to
cp
command to preserve file-datetime, file-stats, etc.:
cp
-a input.txt ./SORT
cp
-a input.txt newname.txt
answered
Mar 12, 2016 at 16:49
This answer is useful
1
Save this answer.
Show activity on this post.
rsync -aAXhv /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
This will copy the
untitelds.mpg
file in the SkyDrive directory without deleting anything
Sparhawk
6,997
7 gold badges
50 silver badges
79 bronze badges
answered
Aug 29, 2015 at 6:43
2
This answer is useful
0
Save this answer.
Show activity on this post.
use
cp
command. Type
man cp
from the terminal for more info.
answered
Mar 12, 2016 at 13:54
You must
log in
to answer this question.
Start asking to get answers
Find the answer to your question by asking.
Ask question
Explore related questions
See similar questions with these tags. |
| Markdown | # 
By clicking “Sign up”, you agree to our [terms of service](https://askubuntu.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://askubuntu.com/legal/privacy-policy).
# OR
Already have an account? [Log in](https://askubuntu.com/users/login)
- [Ubuntu](http://www.ubuntu.com/)
- [Community](http://community.ubuntu.com/)
- [Ask\!](http://askubuntu.com/)
- [Developer](http://developer.ubuntu.com/)
- [Design](http://design.ubuntu.com/)
- [Hardware](http://www.ubuntu.com/certification)
- [Insights](http://insights.ubuntu.com/)
- [Juju](https://jujucharms.com/)
- [Shop](http://shop.ubuntu.com/)
- [More ›](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal)
- [Apps](http://apps.ubuntu.com/)
- [Help](https://help.ubuntu.com/)
- [Forum](http://ubuntuforums.org/)
- [Launchpad](http://www.launchpad.net/)
- [MAAS](http://maas.ubuntu.com/)
- [Canonical](http://www.canonical.com/)
[Skip to main content](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#content)
#### Stack Exchange Network
Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
[Visit Stack Exchange](https://stackexchange.com/)
1. - [Tour Start here for a quick overview of the site](https://askubuntu.com/tour)
- [Help Center Detailed answers to any questions you might have](https://askubuntu.com/help)
- [Meta Discuss the workings and policies of this site](https://meta.askubuntu.com/)
- [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/)
2. ### [current community](https://askubuntu.com/)
- [Ask Ubuntu](https://askubuntu.com/)
[help](https://askubuntu.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=askubuntu.com)
- [Ask Ubuntu Meta](https://meta.askubuntu.com/)
### your communities
[Sign up](https://askubuntu.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983%2Fhow-to-copy-files-via-terminal) or [log in](https://askubuntu.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983%2Fhow-to-copy-files-via-terminal) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
3. [Log in](https://askubuntu.com/users/login?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983%2Fhow-to-copy-files-via-terminal)
4. [Sign up](https://askubuntu.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983%2Fhow-to-copy-files-via-terminal)
[](https://askubuntu.com/)
1. 1. [Home](https://askubuntu.com/)
2. [Questions](https://askubuntu.com/questions)
3. [Unanswered](https://askubuntu.com/unanswered)
4. [AI Assist](https://stackoverflow.com/ai-assist)
5. [Tags](https://askubuntu.com/tags)
6. [Chat](https://chat.stackexchange.com/)
7. [Users](https://askubuntu.com/users)
8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=askubuntu&so_source=SiteNav)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [How to copy files via terminal?](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal)
[Ask Question](https://askubuntu.com/questions/ask)
Asked
13 years, 5 months ago
Modified [9 years, 9 months ago](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal?lastactivity "2016-06-23 18:06:47Z")
Viewed 1.9m times
This question shows research effort; it is useful and clear
189
Save this question.
Show activity on this post.
I have read about copying files with terminal but these examples will help me a lot. So here is what I want to do:
Examples:
1. I have a file in `/home/levan/kdenlive untitelds.mpg` and I want to copy this file to `/media/sda3/SkyDrive` and do not want to delete any thing in SkyDrive directory.
2. I have a file in `/media/sda3/SkyDrive untitelds.mpg` and I want to copy this file to `/home/levan/kdenlive` and do not want to delete any thing in kdenlive directory
3. I want to copy a folder from home directory to `sda3` and do not want to delete any thing on `sda3` directory and opposite
4. I want to cut a folder/file and copy to other place without deleting files in that directory I cut it into.
- [command-line](https://askubuntu.com/questions/tagged/command-line "show questions tagged 'command-line'")
- [bash](https://askubuntu.com/questions/tagged/bash "show questions tagged 'bash'")
[Share](https://askubuntu.com/q/195983 "Short permalink to this question")
Share a link to this question
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this question](https://askubuntu.com/posts/195983/edit)
Follow
Follow this question to receive notifications
[edited Jan 26, 2014 at 20:49](https://askubuntu.com/posts/195983/revisions "show all edits to this post")
[](https://askubuntu.com/users/169736/braiam)
[Braiam](https://askubuntu.com/users/169736/braiam)
69\.5k3333 gold badges182182 silver badges281281 bronze badges
asked Oct 3, 2012 at 15:17
[](https://askubuntu.com/users/42591/levan)
[Levan](https://askubuntu.com/users/42591/levan)
11\.1k2323 gold badges7171 silver badges9595 bronze badges
1
- 2
Simply with `cp -a file.txt newname.txt`.
Avatar
– [Avatar](https://askubuntu.com/users/238253/avatar "107 reputation")
2022-05-30 19:52:56 +00:00
[Commented May 30, 2022 at 19:52](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment2452997_195983)
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 6 Answers 6
Sorted by:
[Reset to default](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal?answertab=scoredesc#tab-top)
This answer is useful
245
Save this answer.
Show activity on this post.
**1\)** By using `-i` for interactive you will be asked if you would like to replace the file:
```
cp -i /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
```
or you can use `-b` to create a backup of your file:
```
cp -b /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive
```
***
**2\)** Same as the above:
```
cp (-i or -b) /media/sda3/SkyDrive/untitelds.mpg /home/levan/kdenlive
```
***
**3\)** Use `-R` for recursive and `-i` for interactive:
```
cp -Ri ~/MyFolder /sda3/
```
***
**4\)** This last one can be done via the `mv` command, move is like cutting:
```
mv -i ~/MyFile ~/OtherFolder/MyFile
```
if you want to move a directory, use:
```
mv -Ri ~/MyDirectory ~/OtherDirectory/
```
[Share](https://askubuntu.com/a/195990 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/195990/edit)
Follow
Follow this answer to receive notifications
[edited Dec 3, 2015 at 22:55](https://askubuntu.com/posts/195990/revisions "show all edits to this post")
[](https://askubuntu.com/users/475757/honey)
[Honey](https://askubuntu.com/users/475757/honey)
11155 bronze badges
answered Oct 3, 2012 at 15:38
[](https://askubuntu.com/users/92745/evandro-silva)
[Evandro Silva](https://askubuntu.com/users/92745/evandro-silva)
9,97266 gold badges3838 silver badges4444 bronze badges
8
- Neat syntax highlighting! Not sure how you triggered that.
Knowledge Cube
– [Knowledge Cube](https://askubuntu.com/users/18612/knowledge-cube "14,971 reputation")
2012-10-03 16:05:48 +00:00
[Commented Oct 3, 2012 at 16:05](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment243786_195990)
- @WarriorIng64 you can use four spaces identation for code blocks, or you can surround small pieces of code with \`s.
Evandro Silva
– [Evandro Silva](https://askubuntu.com/users/92745/evandro-silva "9,972 reputation")
2012-10-03 16:11:50 +00:00
[Commented Oct 3, 2012 at 16:11](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment243791_195990)
- @EvandroSilva I know. I was referring to the fact that some of your code is shown in blue.
Knowledge Cube
– [Knowledge Cube](https://askubuntu.com/users/18612/knowledge-cube "14,971 reputation")
2012-10-03 16:12:43 +00:00
[Commented Oct 3, 2012 at 16:12](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment243792_195990)
- 4
@WarriorIng64 That is triggered by the `bash` tag in the question. highlighting will be enabled by default by the system. If you answer a question with `bash` tag, the hightlighting will follow bash style and so on.
Anwar
– [Anwar](https://askubuntu.com/users/61218/anwar "78,159 reputation")
2012-10-03 16:19:06 +00:00
[Commented Oct 3, 2012 at 16:19](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment243797_195990)
- 2
@Anwar I was just partway through making a [Meta post](http://meta.askubuntu.com/q/4180/18612) on this when I saw your comment. Of course, I credited you in the answer. :)
Knowledge Cube
– [Knowledge Cube](https://askubuntu.com/users/18612/knowledge-cube "14,971 reputation")
2012-10-03 16:24:54 +00:00
[Commented Oct 3, 2012 at 16:24](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment243800_195990)
\| [Show **3** more comments](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Expand to show all comments on this post")
This answer is useful
20
Save this answer.
Show activity on this post.
When `~/Dropbox/RECENT/` is your current directory:
```
cp input.txt SORT/
```
> And I want to copy `input.txt` with another name in my current directory.
Again with `~/Dropbox/RECENT/` as current directory:
```
cp input.txt newname.txt
```
Existing filenames can be auto-completed using `TAB`.
Long version of the same copy command (when you are not in `~/Dropbox/RECENT/`):
```
cp /home/$USER/Dropbox/RECENT/input.txt /home/$USER/Dropbox/RECENT/SORT/
```
I put a `/` behind every directory. If `SORT` does NOT exist a `cp` will also create a file named `SORT` making you think something went wrong. Adding the `/` will have `cp` error out and not copy the file.
[Share](https://askubuntu.com/a/745094 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/745094/edit)
Follow
Follow this answer to receive notifications
[edited Mar 12, 2016 at 16:53](https://askubuntu.com/posts/745094/revisions "show all edits to this post")
[](https://askubuntu.com/users/158442/muru)
[muru](https://askubuntu.com/users/158442/muru)♦
209k5858 gold badges520520 silver badges794794 bronze badges
answered Mar 12, 2016 at 13:59
[](https://askubuntu.com/users/15811/rinzwind)
[Rinzwind](https://askubuntu.com/users/15811/rinzwind)
312k4444 gold badges597597 silver badges747747 bronze badges
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
4
Save this answer.
Show activity on this post.
Use the `cp` command.
Copying a file `something.txt` to file `folder`: use `cp something.txt folder/`
Copying a file `something.txt` to the current directory as `something2.txt`: use `cp something.txt something2.txt`
```
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:53 Folder1
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l Folder1/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:53 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:54 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l folder/
total 0
ubuntu@ubuntu-T100TA:~/TestFolder$ cp something.txt folder/
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l folder/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ cp something.txt something2.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 12
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:55 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something2.txt
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
```
[Share](https://askubuntu.com/a/745093 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/745093/edit)
Follow
Follow this answer to receive notifications
answered Mar 12, 2016 at 13:59
[](https://askubuntu.com/users/481256/the-holy-see)
[The Holy See](https://askubuntu.com/users/481256/the-holy-see)
48444 gold badges77 silver badges1717 bronze badges
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
4
Save this answer.
Show activity on this post.
you will better add the option **\-a** to **cp** command to preserve file-datetime, file-stats, etc.:
```
cp -a input.txt ./SORT
cp -a input.txt newname.txt
```
[Share](https://askubuntu.com/a/745147 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/745147/edit)
Follow
Follow this answer to receive notifications
answered Mar 12, 2016 at 16:49
[](https://askubuntu.com/users/517880/cmks)
[cmks](https://askubuntu.com/users/517880/cmks)
1,94411 gold badge1313 silver badges1717 bronze badges
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
1
Save this answer.
Show activity on this post.
```
rsync -aAXhv /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
```
This will copy the `untitelds.mpg` file in the SkyDrive directory without deleting anything
[Share](https://askubuntu.com/a/667030 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/667030/edit)
Follow
Follow this answer to receive notifications
[edited Sep 6, 2015 at 5:22](https://askubuntu.com/posts/667030/revisions "show all edits to this post")
[](https://askubuntu.com/users/53508/sparhawk)
[Sparhawk](https://askubuntu.com/users/53508/sparhawk)
6,99777 gold badges5050 silver badges7979 bronze badges
answered Aug 29, 2015 at 6:43
[](https://askubuntu.com/users/143132/billv)
[BillV](https://askubuntu.com/users/143132/billv)
6155 bronze badges
2
- I'm not sure why my comment shows up in bold... wasn't intended to.
BillV
– [BillV](https://askubuntu.com/users/143132/billv "61 reputation")
2015-08-29 06:44:38 +00:00
[Commented Aug 29, 2015 at 6:44](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment963463_667030)
- Read the formatting help by clicking the `?` just above the answer field, on the top right.
Sparhawk
– [Sparhawk](https://askubuntu.com/users/53508/sparhawk "6,997 reputation")
2015-09-06 05:23:27 +00:00
[Commented Sep 6, 2015 at 5:23](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal#comment969022_667030)
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
use `cp` command. Type `man cp` from the terminal for more info.
[Share](https://askubuntu.com/a/745092 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/745092/edit)
Follow
Follow this answer to receive notifications
answered Mar 12, 2016 at 13:54
[](https://askubuntu.com/users/228100/vishnu-n-k)
[Vishnu N K](https://askubuntu.com/users/228100/vishnu-n-k)
61566 silver badges2222 bronze badges
[Add a comment](https://askubuntu.com/questions/195983/how-to-copy-files-via-terminal "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
## You must [log in](https://askubuntu.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983) to answer this question.
**[Protected question](https://askubuntu.com/help/privileges/protect-questions)**. To answer this question, you need to have at least 10 reputation on this site (not counting the [association bonus](https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work)). The reputation requirement helps protect this question from spam and non-answer activity.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://askubuntu.com/questions/ask)
Explore related questions
- [command-line](https://askubuntu.com/questions/tagged/command-line "show questions tagged 'command-line'")
- [bash](https://askubuntu.com/questions/tagged/bash "show questions tagged 'bash'")
See similar questions with these tags.
- The Overflow Blog
- [Prevent agentic identity theft](https://stackoverflow.blog/2026/03/27/prevent-agentic-identity-theft/?cb=1)
- [Building shared coding guidelines for AI (and people too)](https://stackoverflow.blog/2026/03/26/coding-guidelines-for-ai-agents-and-people-too/?cb=1)
- Featured on Meta
- [Should the Community Bot stop bumping questions from EOL releases?](https://meta.askubuntu.com/questions/20776/should-the-community-bot-stop-bumping-questions-from-eol-releases?cb=1)
#### Linked
[0](https://askubuntu.com/questions/611450/how-to-copy-and-paste-a-file-through-the-command-line?lq=1 "Question score (upvotes - downvotes)")
[How to copy and paste a file through the command-line?](https://askubuntu.com/questions/611450/how-to-copy-and-paste-a-file-through-the-command-line?noredirect=1&lq=1)
[\-1](https://askubuntu.com/questions/1364319/how-to-copy-a-file-to-a-pendrive-in-ubuntu-terminal?lq=1 "Question score (upvotes - downvotes)")
[How to copy a file to a pendrive in Ubuntu terminal](https://askubuntu.com/questions/1364319/how-to-copy-a-file-to-a-pendrive-in-ubuntu-terminal?noredirect=1&lq=1)
[0](https://askubuntu.com/questions/1208547/simple-question-cp-command?lq=1 "Question score (upvotes - downvotes)")
[simple question cp (command)](https://askubuntu.com/questions/1208547/simple-question-cp-command?noredirect=1&lq=1)
[\-1](https://askubuntu.com/questions/1207202/how-do-i-add-an-image-on-my-computer-to-a-folder-while-using-terminal?lq=1 "Question score (upvotes - downvotes)")
[How do I add an image on my computer to a folder while using terminal?](https://askubuntu.com/questions/1207202/how-do-i-add-an-image-on-my-computer-to-a-folder-while-using-terminal?noredirect=1&lq=1)
[1](https://askubuntu.com/questions/996427/how-to-copy-file-from-etc-to-home?lq=1 "Question score (upvotes - downvotes)")
[How to copy file from etc to home?](https://askubuntu.com/questions/996427/how-to-copy-file-from-etc-to-home?noredirect=1&lq=1)
[0](https://askubuntu.com/questions/745086/how-do-i-copy-a-file-using-terminal?lq=1 "Question score (upvotes - downvotes)")
[How do I copy a file using terminal?](https://askubuntu.com/questions/745086/how-do-i-copy-a-file-using-terminal?noredirect=1&lq=1)
[\-6](https://askubuntu.com/questions/594769/how-to-copy-files-in-terminal-as-root-user?lq=1 "Question score (upvotes - downvotes)")
[How to copy files in Terminal as root user](https://askubuntu.com/questions/594769/how-to-copy-files-in-terminal-as-root-user?noredirect=1&lq=1)
[2](https://askubuntu.com/questions/1198425/pen-drive-not-reading-after-formatting-permission-denied?lq=1 "Question score (upvotes - downvotes)")
[Pen Drive not reading after formatting-Permission denied](https://askubuntu.com/questions/1198425/pen-drive-not-reading-after-formatting-permission-denied?noredirect=1&lq=1)
[2](https://askubuntu.com/questions/276631/ubuntu-12-04-not-loading-after-removing-wine?lq=1 "Question score (upvotes - downvotes)")
[Ubuntu 12.04 not loading after removing Wine](https://askubuntu.com/questions/276631/ubuntu-12-04-not-loading-after-removing-wine?noredirect=1&lq=1)
[1](https://askubuntu.com/questions/536036/copying-files-from-dvd-to-hard-disc?lq=1 "Question score (upvotes - downvotes)")
[Copying files from DVD to hard disc?](https://askubuntu.com/questions/536036/copying-files-from-dvd-to-hard-disc?noredirect=1&lq=1)
[See more linked questions](https://askubuntu.com/questions/linked/195983?lq=1)
#### Related
[4](https://askubuntu.com/questions/67040/using-terminal-i-want-to-copy-some-files?rq=1 "Question score (upvotes - downvotes)")
[Using Terminal I want to copy some files](https://askubuntu.com/questions/67040/using-terminal-i-want-to-copy-some-files?rq=1)
[8](https://askubuntu.com/questions/617629/how-to-enable-cut-or-copy-paste-in-xterm?rq=1 "Question score (upvotes - downvotes)")
[How to enable cut or copy-paste in xterm](https://askubuntu.com/questions/617629/how-to-enable-cut-or-copy-paste-in-xterm?rq=1)
[4](https://askubuntu.com/questions/859761/how-to-delete-orphan-files?rq=1 "Question score (upvotes - downvotes)")
[How to delete orphan files?](https://askubuntu.com/questions/859761/how-to-delete-orphan-files?rq=1)
[4](https://askubuntu.com/questions/1127773/how-to-copy-file-from-a-list-to-a-new-folder?rq=1 "Question score (upvotes - downvotes)")
[How to copy file from a list to a new folder?](https://askubuntu.com/questions/1127773/how-to-copy-file-from-a-list-to-a-new-folder?rq=1)
[6](https://askubuntu.com/questions/1163773/how-can-i-copy-a-directory-without-copying-a-specific-file-or-subdirectory-in-te?rq=1 "Question score (upvotes - downvotes)")
[How can I copy a directory without copying a specific file or subdirectory in terminal?](https://askubuntu.com/questions/1163773/how-can-i-copy-a-directory-without-copying-a-specific-file-or-subdirectory-in-te?rq=1)
[0](https://askubuntu.com/questions/1163999/bash-copy-all-jar-files-to-current-directory-from-subfolders?rq=1 "Question score (upvotes - downvotes)")
[Bash - Copy all .jar files to current directory from subfolders](https://askubuntu.com/questions/1163999/bash-copy-all-jar-files-to-current-directory-from-subfolders?rq=1)
[0](https://askubuntu.com/questions/1337104/copy-files-inside-a-folder-iteratively-bash?rq=1 "Question score (upvotes - downvotes)")
[Copy files inside a folder iteratively - Bash](https://askubuntu.com/questions/1337104/copy-files-inside-a-folder-iteratively-bash?rq=1)
[0](https://askubuntu.com/questions/1357854/copying-files-from-the-terminal-with-confirmation-message-before-copying-each-fi?rq=1 "Question score (upvotes - downvotes)")
[Copying files from the terminal with confirmation message before copying each file](https://askubuntu.com/questions/1357854/copying-files-from-the-terminal-with-confirmation-message-before-copying-each-fi?rq=1)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [References on computability and intuitionism](https://mathoverflow.net/questions/509560/references-on-computability-and-intuitionism)
- [Can a space be a countable union of compact but not closed and compact subspaces?](https://math.stackexchange.com/questions/5130486/can-a-space-be-a-countable-union-of-compact-but-not-closed-and-compact-subspaces)
- [41 years of confusing Windows version naming](https://codegolf.stackexchange.com/questions/287682/41-years-of-confusing-windows-version-naming)
- [8087 FPTAN/FPATAN Behavior](https://retrocomputing.stackexchange.com/questions/32553/8087-fptan-fpatan-behavior)
- [Poor shifting after new chain](https://bicycles.stackexchange.com/questions/100108/poor-shifting-after-new-chain)
- [Total energy production of a neutrino powered generator](https://worldbuilding.stackexchange.com/questions/272998/total-energy-production-of-a-neutrino-powered-generator)
- [How can I check identities of matrix elements given some matrix relations?](https://mathematica.stackexchange.com/questions/319099/how-can-i-check-identities-of-matrix-elements-given-some-matrix-relations)
- [How many translation lines do we need to have a Moufang plane?](https://mathoverflow.net/questions/509587/how-many-translation-lines-do-we-need-to-have-a-moufang-plane)
- [When do you abandon an approach, or try to prove the opposite result?](https://mathoverflow.net/questions/509561/when-do-you-abandon-an-approach-or-try-to-prove-the-opposite-result)
- [D'Alembert's Principle and its relation to the derivation of Lagrangian mechanics](https://physics.stackexchange.com/questions/870635/dalemberts-principle-and-its-relation-to-the-derivation-of-lagrangian-mechanic)
- [If I installed both GOG and Steam No Man's Sky, would their universes be separate?](https://gaming.stackexchange.com/questions/418257/if-i-installed-both-gog-and-steam-no-mans-sky-would-their-universes-be-separat)
- [What does 'placard' mean here?](https://ell.stackexchange.com/questions/374411/what-does-placard-mean-here)
- [Unopened Brie Use by Date](https://cooking.stackexchange.com/questions/136809/unopened-brie-use-by-date)
- [Is Chinese language so difficult to understand that even the author himself fails?](https://chinese.stackexchange.com/questions/64021/is-chinese-language-so-difficult-to-understand-that-even-the-author-himself-fail)
- [When to use fateor and confiteor?](https://latin.stackexchange.com/questions/27144/when-to-use-fateor-and-confiteor)
- [feature generating strategy](https://datascience.stackexchange.com/questions/137866/feature-generating-strategy)
- [What are my license obligations when distributing a statically linked executable?](https://opensource.stackexchange.com/questions/15724/what-are-my-license-obligations-when-distributing-a-statically-linked-executable)
- [Did everything between Genesis 2:7-25 happen on day six of creation (Genesis 1:24-31)?](https://hermeneutics.stackexchange.com/questions/115569/did-everything-between-genesis-27-25-happen-on-day-six-of-creation-genesis-12)
- [If an emoji renders differently on two devices due to compatibility issues, whose interpretation is valid?](https://law.stackexchange.com/questions/114460/if-an-emoji-renders-differently-on-two-devices-due-to-compatibility-issues-whos)
- [Why does the hook in \\chapter fail?](https://tex.stackexchange.com/questions/761277/why-does-the-hook-in-chapter-fail)
- [Who Advises the President on the Legality of Military Force?](https://politics.stackexchange.com/questions/94445/who-advises-the-president-on-the-legality-of-military-force)
- [In an Ansible INI file, does a blank line break a group?](https://unix.stackexchange.com/questions/805183/in-an-ansible-ini-file-does-a-blank-line-break-a-group)
- [Acoustically speaking, are Norse "hunting horns" going to sound similar to Jewish shofars?](https://music.stackexchange.com/questions/143408/acoustically-speaking-are-norse-hunting-horns-going-to-sound-similar-to-jewis)
- [How idiomatic is the term "library person" in this context?](https://ell.stackexchange.com/questions/374405/how-idiomatic-is-the-term-library-person-in-this-context)
[Question feed](https://askubuntu.com/feeds/question/195983 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-bash
# Why are you flagging this comment?
It contains harassment, bigotry or abuse.
This comment attacks a person or group. Learn more in our [Abusive behavior policy](https://askubuntu.com/conduct/abusive-behavior).
It's unfriendly or unkind.
This comment is rude or condescending. Learn more in our [Code of Conduct](https://askubuntu.com/conduct/abusive-behavior).
Not needed.
This comment is not relevant to the post.
```
```
Enter at least 6 characters
Something else.
A problem not listed above. Try to be as specific as possible.
```
```
Enter at least 6 characters
Flag comment
Cancel
You have 0 flags left today
# 
# Hang on, you can't upvote just yet.
You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation)
Instead, you can save this post to reference later.
Save this post for later
Not now
##### [Ask Ubuntu](https://askubuntu.com/)
- [Tour](https://askubuntu.com/tour)
- [Help](https://askubuntu.com/help)
- [Chat](https://chat.stackexchange.com/?tab=site&host=askubuntu.com)
- [Contact](https://askubuntu.com/contact)
- [Feedback](https://meta.askubuntu.com/)
##### [Company](https://stackoverflow.co/)
- [Stack Overflow](https://stackoverflow.com/)
- [Stack Internal](https://stackoverflow.co/internal/)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/)
- [Stack Ads](https://stackoverflow.co/advertising/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.27.41560
Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence. |
| Readable Markdown | This question shows research effort; it is useful and clear
189
Save this question.
Show activity on this post.
I have read about copying files with terminal but these examples will help me a lot. So here is what I want to do:
Examples:
1. I have a file in `/home/levan/kdenlive untitelds.mpg` and I want to copy this file to `/media/sda3/SkyDrive` and do not want to delete any thing in SkyDrive directory.
2. I have a file in `/media/sda3/SkyDrive untitelds.mpg` and I want to copy this file to `/home/levan/kdenlive` and do not want to delete any thing in kdenlive directory
3. I want to copy a folder from home directory to `sda3` and do not want to delete any thing on `sda3` directory and opposite
4. I want to cut a folder/file and copy to other place without deleting files in that directory I cut it into.
[](https://askubuntu.com/users/169736/braiam)
[Braiam](https://askubuntu.com/users/169736/braiam)
69\.5k33 gold badges182 silver badges281 bronze badges
asked Oct 3, 2012 at 15:17
[](https://askubuntu.com/users/42591/levan)
1
This answer is useful
245
Save this answer.
Show activity on this post.
**1\)** By using `-i` for interactive you will be asked if you would like to replace the file:
```
cp -i /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
```
or you can use `-b` to create a backup of your file:
```
cp -b /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive
```
***
**2\)** Same as the above:
```
cp (-i or -b) /media/sda3/SkyDrive/untitelds.mpg /home/levan/kdenlive
```
***
**3\)** Use `-R` for recursive and `-i` for interactive:
```
cp -Ri ~/MyFolder /sda3/
```
***
**4\)** This last one can be done via the `mv` command, move is like cutting:
```
mv -i ~/MyFile ~/OtherFolder/MyFile
```
if you want to move a directory, use:
```
mv -Ri ~/MyDirectory ~/OtherDirectory/
```
[](https://askubuntu.com/users/475757/honey)
answered Oct 3, 2012 at 15:38
[](https://askubuntu.com/users/92745/evandro-silva)
8
This answer is useful
20
Save this answer.
Show activity on this post.
When `~/Dropbox/RECENT/` is your current directory:
```
cp input.txt SORT/
```
> And I want to copy `input.txt` with another name in my current directory.
Again with `~/Dropbox/RECENT/` as current directory:
```
cp input.txt newname.txt
```
Existing filenames can be auto-completed using `TAB`.
Long version of the same copy command (when you are not in `~/Dropbox/RECENT/`):
```
cp /home/$USER/Dropbox/RECENT/input.txt /home/$USER/Dropbox/RECENT/SORT/
```
I put a `/` behind every directory. If `SORT` does NOT exist a `cp` will also create a file named `SORT` making you think something went wrong. Adding the `/` will have `cp` error out and not copy the file.
[](https://askubuntu.com/users/158442/muru)
[muru](https://askubuntu.com/users/158442/muru)♦
209k58 gold badges520 silver badges794 bronze badges
answered Mar 12, 2016 at 13:59
[](https://askubuntu.com/users/15811/rinzwind)
This answer is useful
4
Save this answer.
Show activity on this post.
Use the `cp` command.
Copying a file `something.txt` to file `folder`: use `cp something.txt folder/`
Copying a file `something.txt` to the current directory as `something2.txt`: use `cp something.txt something2.txt`
```
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:53 Folder1
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l Folder1/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:53 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:54 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l folder/
total 0
ubuntu@ubuntu-T100TA:~/TestFolder$ cp something.txt folder/
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l folder/
total 4
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ cp something.txt something2.txt
ubuntu@ubuntu-T100TA:~/TestFolder$ ls -l
total 12
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 12 21:55 folder
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:55 something2.txt
-rw-rw-r-- 1 ubuntu ubuntu 14 Mar 12 21:52 something.txt
```
answered Mar 12, 2016 at 13:59
[](https://askubuntu.com/users/481256/the-holy-see)
This answer is useful
4
Save this answer.
Show activity on this post.
you will better add the option **\-a** to **cp** command to preserve file-datetime, file-stats, etc.:
```
cp -a input.txt ./SORT
cp -a input.txt newname.txt
```
answered Mar 12, 2016 at 16:49
[](https://askubuntu.com/users/517880/cmks)
This answer is useful
1
Save this answer.
Show activity on this post.
```
rsync -aAXhv /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/
```
This will copy the `untitelds.mpg` file in the SkyDrive directory without deleting anything
[](https://askubuntu.com/users/53508/sparhawk)
[Sparhawk](https://askubuntu.com/users/53508/sparhawk)
6,9977 gold badges50 silver badges79 bronze badges
answered Aug 29, 2015 at 6:43
[](https://askubuntu.com/users/143132/billv)
2
This answer is useful
0
Save this answer.
Show activity on this post.
use `cp` command. Type `man cp` from the terminal for more info.
answered Mar 12, 2016 at 13:54
[](https://askubuntu.com/users/228100/vishnu-n-k)
## You must [log in](https://askubuntu.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F195983) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://askubuntu.com/questions/ask)
Explore related questions
See similar questions with these tags. |
| Shard | 53 (laksa) |
| Root Hash | 9277990770814737653 |
| Unparsed URL | com,askubuntu!/questions/195983/how-to-copy-files-via-terminal s443 |