Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm just trying to copy the folder present in /home/black/Desktop/linux to another folder present in /home/black/Desktop/ubuntu

now what i /home/black/Desktop/linux now am there in linux folder in Desktop. Then:

 cp -r linux/ /home/black/Desktop/ubuntu
 no such file or directory

Between when i am copying the content from linux folder like .txt file to another directory i can do that smoothly. so y use -r when copying folder?

share|improve this question
up vote 1 down vote accepted
cp -r /home/black/Desktop/linux /home/black/Desktop/ubuntu

If there is a specific folder in the linux folder, you will need to add that folder to the source path. The source and destination paths need to be separated by a space. Your original command likely failed because you you used a source path of linux/ and the trailing / leaves an undefined path in the command. Using the -r invokes recursive copying to copy all the contents of the directory.

share|improve this answer
thnx man. so for copying i dont need to goto in that directory from where it will copy? – black Dec 23 '13 at 15:20
Copying can take place from whatever directory you are currently working in - you just have to use absolute file paths. You can copy using relative file paths only when the copying is taking place in the same current working directory in your shell. – douggro Dec 23 '13 at 15:25

Try this:

cp -Ri ~/Desktop/linux ~/Desktop/ubuntu
share|improve this answer
thank you it also worked. figured out ~ but what is -Ri – black Dec 23 '13 at 15:15
if you do like this,linux folder won't delete. – Avinash Raj Dec 23 '13 at 15:17
try this command cp --help,see the meaning for R and i. – Avinash Raj Dec 23 '13 at 15:19
ok. ty so much. +1 vote for you after 15rep :D – black Dec 23 '13 at 15:23
if you doesn't want linux folder in the desktop and moving the linux folder into the ubuntu folder then run this command mv -i ~/Desktop/linux ~/Desktop/ubuntu – Avinash Raj Dec 23 '13 at 15:23

I prefer copying with this format: cp [OPTION]... -t TARGET_FOLDER SOURCE_FILE_OR_FOLDERS...

e.g.1 Copying a single directory/folder:

cp -rv -t /home/black/Desktop/ubuntu /home/black/Desktop/linux

e.g.2 Copying multiple directories:

cp -rv -t /home/black/Desktop/ubuntu /home/black/Desktop/linux /home/black/Desktop/someOtherFileOrFolder

e.g.3 Copying multiple directories and files:

cp -rv -t /home/black/Desktop/ubuntu /home/black/Desktop/linux /home/black/Desktop/someOtherFileOrFolder /home/black/Documents/myFile.txt

e.g.4 Copying multiple directories and files:

cp -ruv -t /home/black/Desktop/ubuntu /home/black/Desktop/linux /home/black/Desktop/someOtherFileOrFolder /home/black/Documents/myFile.txt

with parameters r and t for recursive and verbosity options.

A little about the switches:

-r for recursive copy (copy folder all contents including sub-directory structure and contents)

-u copy only when the SOURCE file is newer than the destination file or when the destination file is missing

-v outputs the copy operations performed.

share|improve this answer
oh.. cool edit ty man. – black Dec 23 '13 at 15:35
i use this very often to backup my files to external HDD... and for backup operations one more switch -u (--update) is really good one for me... :) – precise Dec 23 '13 at 15:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.