Questions tagged [cp]

Questions relating to the Linux 'cp' command.

213 questions
1196
votes
8 answers

How can I copy the contents of a folder to another folder in a different directory using terminal?

I am trying to copy the contents of a folder to another folder in a different directory using terminal. Would somebody be able to provide me an example of the command line syntax required to achieve this?
pandisvezia
  • 12,181
  • 3
  • 14
  • 7
470
votes
7 answers

What does "cp: omitting directory" mean?

I've issued the following command: sudo cp ~/Transfers/ZendFramework-1.11.4-minimal/library/Zend/* ~/public_html/cmsk.dev/library/ When I do this, I start getting the following messages: cp: omitting directory `Tag' cp: omitting directory `Test'…
MEM
  • 10,817
  • 12
  • 37
  • 42
106
votes
7 answers

how do you copy a directory and its contents to a new location under a new directory name?

I'm new to the Linux command line and am trying to get to grips with the copy command at the moment. Can anyone please tell me if it's possible to copy a directory with its subdirectories and associated files to a new directory with a new name, e.g.…
Edmuntu
  • 1,073
  • 2
  • 8
  • 6
91
votes
9 answers

How to copy a file to multiple folders using the command line?

I have tried to copy a file test.txt to multiple directories with one command: cp ~/test.txt ~/folder1 ~/folder2 But I didn't succeed. Is there a way to do that in one command so I can copy a file or even a folder to multiple directories?
nux
  • 36,031
  • 33
  • 115
  • 130
86
votes
2 answers

Copy a file and keep the same timestamp of the original file

I need to a copy file and after that I need to change the timestamp attributes as the original file. How can I do it with the terminal or any other way?
user829468
62
votes
4 answers

cp command to exclude certain files from being copied

Is there a way to use the cp command to copy a directory and exclude certain files/sub-directories within it?
Stephen Jacob
  • 809
  • 2
  • 9
  • 10
56
votes
5 answers

Can I verbose output during a copy command processing?

Situation: If I entered a copy command like cp -rf /src/ /dsc/ then I am waiting several minutes for copy large directories. I forgot to put -v flag to verbose an output, Can I do it during copying?
Smile.Hunter
  • 7,865
  • 10
  • 32
  • 35
40
votes
5 answers

cp - cannot create regular file : permission denied

I want copy to /lib/udev but gives error cp -f /tmp/ok_pcscd_hotplug.sh /lib/udev cp:cannot create regular file /lib/udev/ok_pcscd_hotplug : Permission denied I am root , but I can't understand . what can I do ?
user278122
  • 421
  • 1
  • 4
  • 4
25
votes
2 answers

Copy the content/file to all subdirectory in a directory using terminal

I want to copy a file to all subfolders in a folder. How can I do this with the command line?
22lk94k943 only
  • 1,053
  • 2
  • 16
  • 25
21
votes
2 answers

What's the difference between ` cp ` and ` rsync `?

They seem similar to me. I want to know how to use them. What's the difference in structure?
Thái Siu Nhưn
  • 319
  • 1
  • 2
  • 4
21
votes
2 answers

Copy only folders not files?

Is there a way to copy an entire directory, but only the folders? I have a corrupt file somewhere in my directory which is causing my hard disks to fail. So instead of copying the corrupt file to another hard disk, I wanted to just copy the folders,…
Shannon
  • 221
  • 1
  • 2
  • 5
21
votes
3 answers

How to copy a directory from one hard drive to another with every single file?

I have a folder I just luckily recovered sitting on: /media/sdc1/Pictures with a BUNCH of subdirectories and files that I need. I want to copy these to a folder on: /media/sdb1/Pictures What command do I have to use in the terminal to make sure…
wardr
  • 2,059
  • 3
  • 19
  • 21
20
votes
2 answers

force cp to copy on dangling symlinks

Is there any way to force cp (Bash 4.2.5, Ubuntu 12.04) to copy onto a dangling symlink? cp a-file path/to/danling/symlink/a-file cp: not writing through dangling symlink `path/to/danling/symlink/a-file` cp -f seems to be impotent in this case and…
Marcus Junius Brutus
  • 747
  • 4
  • 11
  • 29
18
votes
2 answers

Is there any way to create backup copy of a file, without type its name twice?

Often when I'm editing some system file first I create a backup copy. For example: sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak Is there any simple 'shortcut' such as: sudo cp /etc/ssh/sshd_config %s.bak ? A workaround that I found is to…
pa4080
  • 28,091
  • 10
  • 83
  • 153
18
votes
2 answers

Ubuntu copying file problem (cannot stat file)

I've faced a problem when copying a file with the commands, cp ~/Downloads/sample.pdf ~/Desktop/ But the terminal gives me a message, cp: cannot stat 'sample.pdf': No such file or directory.
Herks
  • 833
  • 2
  • 11
  • 19
1
2 3
14 15