Questions tagged [cp]

cp - Command-line tool to copy a file

48 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
522 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
1answer
171 views

Can rsync pick up where an interrupted cp left off?

If I use cp to copy a very large file over the course of several hours and decide to stop the operation, can rsync be used to complete the operation at a later point without needeing to re-write data?
3
votes
3answers
92 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
48 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
57 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
508 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 = "...
2
votes
0answers
206 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
166 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
989 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
447 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
108 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
1answer
35 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
46 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
477 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
41 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
75 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
235 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
55 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
437 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
105 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
1answer
961 views

How to copy directory and ignore errors

I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question. I want to find ...
1
vote
0answers
564 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
898 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
293 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
600 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
202 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
651 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
92 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
896 views

cp with interactive don't prompt before overwrite

I observed a strange behavior cp. Exactly the point is that cp did not ask me for confirmation, even with the option interactive. A test case looks like this Existing files find * -type f app/file....
1
vote
1answer
586 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
55 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
910 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
29 views

cp from locally mounted sshfs corrupting .gz files

I have used sshfs to locally mount a SFTP server's filesystem. I am trying to copy .gz files from the sshfs mount (/mnt/mysftp/) to /tmp and noticed when the file is large (~10MB+), it will copy over ...
0
votes
1answer
65 views

Copy files from remote machine to folder on remote machine

Why do we get the following error about "No such file or directory" when we copy files from remote folder to another remote folder? ssh -n -o ConnectTimeout=50 -o StrictHostKeyChecking=no -xaq $IP ...
0
votes
2answers
31 views

Copying diff results files

I have two folders - Folder A and Folder B. I compared the files from both folders using diff command. Now after finding that certain files are only available in Folder A and Certain files in Folder ...
0
votes
0answers
38 views

Can I specify a size space while using mount command?

I mount a *.img file, and want to copy some new files into it. But there is not enough space for me to place new files. Can I specify more size space while I use mount. ./Image: No space left on ...
0
votes
3answers
89 views

Sort and copy files from several directories

I have a directory containing several sub-directories, containing files. I would like to sort the files in each of these directories by name alphabetically and copy the first file from each ...
0
votes
2answers
384 views

Find and copy with xargs doesn't work in a script

I need to find three files from a huge directory and copy them to another directory. This is what I have done: find $adir -type f \( -name "a1*" -o -name "a2*" -o -name "a3*" \) -mtime -8 | xargs cp ...
0
votes
1answer
509 views

Hard disk usage 100 % without any read or write activity

I started a big file transfer and it's taken a long time. I checked the disk activity with nmon and it says the (NTFS) disk is being 100 % busy and read and write speeds are at zero. I used cp -r ...
0
votes
1answer
154 views

cp/rsync both grind to a halt when copying to USB/Micro SD

I'm trying to transfer about 20GB of music from my Arch Linux laptop to a Micro SD card, via a USB reader. The process starts off fine; the first ~50 songs take a combined one second, although from ...
0
votes
1answer
221 views

Cron to find exec cp and redirect output with time / date per line?

I try to setup a cron task to run a set of basic shell commands. I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date ...
0
votes
1answer
56 views

FreeBSD 9.3 and OSX color tags

I am using nas4Free 9.3.2 and FreeBSD 9.3-RELEASE-p22. I noticed after using cp, that my moved files no longer had the color coded labels I had applied in OSX. Share mounted in AFP. To test this, I ...
-1
votes
2answers
57 views

Copying files while maintaining file attributes

Say, if I want to copy /etc/bin to a folder while maintaining the file attributes as well as parent directories. [The target folder should not just contain bin folder but /etc/bin.] Is the possible ...
-1
votes
1answer
65 views

Copy Month wise folders

Main_Dir | --------------------------------------------------------------------- Subdir1 Subdir2 Subdir3 ...
-3
votes
1answer
289 views

How to copy a sub directory of one directory to another?

How can I copy a directory structure named function under Dept2 directory into Dept3 directory in one shot?
-6
votes
1answer
74 views

What is the meaning of -r and -R in copy command?

I read that they stand for recursively in the man page. However, I am not sure what their role is in the command. When I tried to copy some empty directory into another directory with, $ cp EMPDIR ...