Questions tagged [cp]

cp - Command-line tool to copy a file

66 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
85 views

What should 'cp -r srcpath/.. dstpath' do?

Consider the following: /tmp$ mkdir -p src/{a,b} dst/dstsub; touch src/{a,b}/hello /tmp$ tree src/ dst/ src/ ├── a │   └── hello └── b └── hello dst/ └── dstsub Now run /tmp$ cp -r src/a/.. dst/...
4
votes
1answer
634 views

How to force Fedora 27 to write to USB flash drive immediately?

My Fedora 27 writes actual data to USB on umount. Before umount it works only with links or something like that. So, for example, when I transfer a big file of 5 GB cp /home/iam/bigFile /run/mnt/iam/...
3
votes
3answers
96 views

Can I forbid the creation of files with certain permissions?

I have a directory with a certain group ID, and I only want files with the same ID to be in that directory. So I set the SGID bit on that directory, so that everytime a file is created inside it, it ...
2
votes
0answers
298 views

Using cp to copy ~/.config to an external drive but getting “cannot create regular file…File exists” errors

The command is simple enough, executed while in a subdirectory of /mnt/e, an external drive: cp -r ~/.config .. Every time, every time I run it, the same set of files refuse to copy properly: cp: ...
2
votes
0answers
183 views

A linux “cp” command equivalent that does read/write threading and buffer sharing for increased throughput?

First, let me address your concerns. I'm copying from one slow drive, to another (different) slow drive. Blocking for reads on one drive until I write to another leaves a lot of room for improvement. ...
2
votes
0answers
222 views

Copy file if no error was encountered, else delete copied portion

I am copying a folder in Linux with plenty of files. Some of the files give me errors like this: Error splicing file: Input/output error The problem is that it keeps the file in the new location ...
2
votes
1answer
169 views

exec cp failes from script, yet works when issued directly

I have a script that copies SQL backups to a windows server. Here's the line from /etc/fstab: //my.win.box/share$ /winshare cifs credentials=/etc/credfile,dom=mydomain,uid=0,gid=0,file_mode=...
2
votes
1answer
1k views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
2
votes
1answer
1k views

Can't copy files into directory which has enough group permissions

I would like to do this: XXXX:xxxadm 53> cp /user/uz408217/transporty/K900730.ZAT /usr/sap/trans/cofiles But end up with this error: cp: cannot create regular file `/usr/sap/trans/cofiles/...
2
votes
3answers
282 views

How to copy just certain words from a file into a new file

I have a homework assignment where I have a file that is a large list of words. I have to copy into a new file all the words starting with c and name it cwords. I can see a list of the words by ...
1
vote
0answers
20 views

Diskless root filesystem starts to break when copied to a new location

I am pxe booting using nfs to get a diskless cluster. When doing testing I wanted to make a copy of the directory used by the nodes to mount the linux root filesystem. But after copying the file over ...
1
vote
0answers
40 views

scripting: how to cp (or rsync) same files (and filenames) with autorenaming and mantaining .ext

I want to write a simple bash script (for loop). After obtaining a list of wanted files, eg:find /start/* -iname "*.txt" > txt.list I'd like to copy all of them inside an unique destination with ...
1
vote
0answers
102 views

Alternatives to dd to read/write to a disk?

I'm using cp to read/write from an SSD drive but is not fast enough. Then I used dd, which is fast, especially with the drive unpartitioned. But I ran into errors like there is no space left on ...
1
vote
1answer
75 views

Is it safe to copy a directory while the contents are constantly changed?

I want to backup a shared directory with lots of smalls files, which are constantly changed by my users (add/delete/edit). As usual, I use tar and filter the content through a compression program like ...
1
vote
1answer
119 views

Attempting to only copy files that have changed within the last day while maintaining folder structure

I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data ...
1
vote
1answer
264 views

How to use 'find' and 'cpio' to exclude parent directories

I want to copy over all html files in a nested directory but I want to prevent the parent folders above it from being generated as well. That is if my source path is /project/ng1/src/templates/**, ...
1
vote
1answer
1k views

No such file or directory during rsync/cp copy command

I am trying to copy my entire shares directory from one server to my current directory. Running the command: rsync -avhP /shares . it will copy 90% of the data to that directory but I am getting ...
1
vote
1answer
53 views

find files with particular attributes, rename them to their directory name, copy them elsewhere

It won't look like it, but I've spent 3+ hours trying to figure this out... I am trying to identify files in all subdirectories of a parent directory with particular attributes (name and size) then ...
1
vote
0answers
126 views

`cp` fails writing to file / directory while `cat >` and `echo` work fine

On a RHEL 7.2 based system I try to copy files to a smb mounted location: cd /target cp /tmp/foo . This fails with this error message: cp: cannot create regular file ‘./foo’: Operation not ...
1
vote
0answers
411 views

See the overall percentage completion of a recursive cp command

Is it a simple way to track the completion of a large cp -r command? To get something like: copying 10% ... copying 20% Maybe using a pipe to another command? cp -rvv orig dest | show_as_percent ...
1
vote
0answers
62 views

what is the best approach to move /var?

we have linux red hat 7 we want to keep the /var on other volume so the plan is to: mkdir /var_copy cp -rp /var/* /var_copy umount /dev/mapper/vg-a-var /var rm -rf /var mkdir /var mount /dev/...
1
vote
0answers
662 views

cp on nfs share claims to fail but actually succeeds

I am dealing with an nfs share where I have read/write permissions. Everything seems to work fine, except when I copy files to subdirectories. Then the cp command complains that file creation was ...
1
vote
1answer
109 views

How to copy a certain amount of sorted files? (e.g. 11 GB)

I'd like to copy a total of 11 GB of files (all of the type .mp3 for the sake of this question) from folder ~/ABC/ to ~/DEF/. And I like to do that for the files sorted descending by date last edited/...
1
vote
0answers
801 views

Why cp/mv can't be interrupted until the end of the current file

Let's say I want to copy 3 large files (4Gb each) with this command : cp -v file1 file2 file3 dest_directory/ When cp is copying the second file, and I press CTRL+C, the copy is not canceled until ...
1
vote
0answers
58 views

Can cp -r replace the cp -a in this case?

If I understand correctly the option cp -a someDir is essentially to archive a dir i.e. to copy its contents/structure and preserve access time & access rights. And it differs with cp -r someDir ...
1
vote
1answer
1k views

Sync two Directories without rsync

I know what you are thinking right now "Just use rsync" but unfortunately this system does not have rsync, and I would like to come up with another solution. The Setup: The source Server has a ...
1
vote
0answers
363 views

Centos 7 Random Panic / Oops

Finally after much configuration changes I got a complete a crash dump I could inspect: KERNEL: /usr/lib/debug/lib/modules/3.10.0-327.28.3.el7.x86_64/vmlinux DUMPFILE: vmcore [PARTIAL DUMP] ...
1
vote
0answers
638 views

On MAC OS X 10.11.4 - Loss of extended file attribute when copying a file

I have a file with a comment as extended attribute. This is how I can see the attribute from the Terminal: mdls -name kMDItemFinderComment path_to_file I get the answer kMDItemFinderComment = "...
1
vote
0answers
777 views

Copies to NFS server write to mount point, not to mounted drive

I have a drive mounted at /home/ftpuser/uploads, and the /home/ftpuser folder is also exported via NFS. FTP uploads to the uploads folder work as intended. If I unmount the drive, the files disappear, ...
1
vote
0answers
224 views

Live OS freezes while copying files

I was trying to backup many files (~10,000) from a hard drive on an OS-less notebook to an external 500 GB HDD, so I booted up the Fedora 22 Live XFCE spin using a USB, started the copy and after 5 ...
1
vote
2answers
822 views

How to copy and rename file listed in TXT file?

I need to copy all files listed in TXT file from one location to another location. /1132526906_tt_nad87_1.jpg /thumb/t1132526906_tt_nad87_1.jpg /1132526906_tt_nad87_10.jpg /thumb/...
1
vote
0answers
94 views

Light file copy with diff

Is there a way to copy a file by creating another instance of it, that is not created as a hard copy, but by a link with the difference that any edit to that file will be saved in an diff file? I ...
1
vote
1answer
612 views

Linux command to copy as hard links, while deleting unwanted files?

I'm looking for a command that behaves both like cp -al in only creating hard links rather than copying file contents, and rsync -a --delete in removing files from the destination that are not ...
1
vote
0answers
66 views

How to be certain “cp -n -r /dir/ /des/” does not overwrite files.. and is doing its job ? verbose mode?

I run the command cp -n -r /dir/ /backup/ but there is no way to tell what it is doing.. if it is skipping files that already exists.. if it is doing anything.. I tried adding -v option to it....
1
vote
1answer
2k views

How do I force move something when sudo mv -f doesn't work?

I need to move a 16 GB folder to my external drive, but moving it manually gives me an in use error. I have tried to start in safe mode and moved it but it was still in use. I have run these commands ...
1
vote
0answers
984 views

Can't make a copy of /var/lib/mysql/ibdata1

I have a RedHat Linux server and I'm trying to make a copy of /var/lib/mysql/ibdata1, but I'm receiving an error saying permission denied and the file cannot be opened. I'm logged in as root user and ...
0
votes
0answers
16 views

I get this error when copying some files with rsync: “rysnc: read errors mapping “…” input/output error” - I can open and watch the file in VLC

I am using rsync to clone hundreds of video files to another hard drive. There were 3 files which had the exact error as below: rsync: read errors mapping "/var/run/importcopy/tmpdir/dev/da1s1/...
0
votes
0answers
17 views

Can someone please explain in lay-mans terms what cp -arxpf does?

I'm inept at understanding the manual apparently. I read 'sudo cp -arxpf...' Can someone please explain to an idiot (me) what the -arxpf options do in the copying? Thanks in advance, Rob
0
votes
2answers
18 views

copy a directory into another directory and create intermediate directories

I would like to copy the whole /usr/share/zoneinfo/ directory into /var/www/clients/client1/web5/./usr/share/zoneinfo/. (The /./ is added for clarity and formatting purposes) The directory /var/www/...
0
votes
0answers
30 views

cp copies from hard drive to USB 3.0 stick with transfer speed below 1.7MB/s!

Aspire One Cloudbook 14 (A01-431-C8G8) Linux kernel 4.19 Debian 10 Hi: I have a USB 3.0 pendrive (stick) plugged into a USB 3.0 slot in the laptop. I copied (cp) all files in one of the laptop ...
0
votes
0answers
46 views

single command to `mv`/rename/move a file and set the user, group & permissions?

I can copy a file with cp. But with install I can copy a file, and set the owner, group and permissions on the new destination file, which is useful. With mv, I can rename/move a file, which (if it's ...
0
votes
0answers
26 views

copying file inside shell script is producing error

I've been trying to copy large number of files from one partition to another. The command works smoothly directly in the shell but once I put it in a script I get this error: /media/My.../source/...
0
votes
1answer
32 views

Reflink copy diff

I want to make a behaviour like btrfs send and btrfs receive, but on a per-file basis. As far as I see it, I can use cp -ax --reflink=always to make a "snapshot" of the file. Let's assume that two ...
0
votes
0answers
10 views

Unable to copy files from VMFS mount

Using vmfs-tools and the following syntax: vmfs-fuse filename.E01 /mnt/mounted_place works fine. While using ll -h I am able to view the contents of the mounted drive. My goal is to move all the ...
0
votes
0answers
35 views

find exec cp - copy files without overwriting duplicates

I've got a few directories with matching file names: Foo/ one.pdf two.pdf three.pdf Bar/ one.pdf two.pdf three.pdf Baz/ one.pdf two.pdf three.pdf ...and I want to move all files ...
0
votes
0answers
24 views

How to copy files from linux rhel6 to another rhel6 (which are not connected)?

How to copy files or folders from linux rhel6 server to another (which are not connected) with same file or folder properties (especially symlinks) using zip? The only way is FTP to server1 and copy ...
0
votes
2answers
95 views

Using cp's interactive option for saving text from stdin

In an interactive shell script I'd like to save the output of a command to a file like in $ echo "Hello, World" > test.txt but prevent test.txt to be overwritten if it already exists. So I ...
0
votes
1answer
11 views

Copying a list of test/path/to/files to list of prod/path/to/files

I would like to copy a list of files in the form test/path/to/file/filename.xyz to their corresponding production path prod/path/to/file/filename.xyz. If the test path and the prod path are the same ...
0
votes
1answer
107 views

cp / rsync - Overwrite if smaller, backup original and then overwrite if larger

I have files in Folder A than I want to copy in Folder B. Folder B contains some files by the same name. Timestamps on all files are the same and I want to overwrite and backup larger files of the ...
0
votes
0answers
100 views

Simultaneous copy from multiple sources without fragmenting destination

I regularly need to copy large datasets from multiple smaller drives to a larger one. Lately I've been using a WD Easystore 12TB External USB 3.0 Hard Drive as my destination. Copying all the files ...