Questions relating to the Linux 'cp' command.
Questions tagged [cp]
226 questions
1365
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
- 13,881
481
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
- 11,255
134
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,353
125
votes
3 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
108
votes
10 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
- 39,152
81
votes
5 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
- 999
- 3
- 9
- 11
68
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
- 8,705
43
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
- 451
31
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,143
25
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
- 30,621
24
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…
24
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
- 251
22
votes
1 answer
What is the difference in using cp and dd when cloning USB sticks?
I found that there are at least two methods to clone a USB stick:
(with /dev/sdb as the source while /dev/sdc the target)
Cloning with cp:
sudo cp /dev/sdb /dev/sdc
Cloning with dd:
sudo dd if=/dev/sdb of=/dev/sdc bs=4096
Are there any…
MrWm
- 325
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
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,429