Questions tagged [cp]
cp is the copy command.
73
questions
0
votes
1
answer
37
views
How to make cp report an error when file was not copied?
I am using cp command with -n option meaning if the target file exists it should not be overwritten, in short -- file is not copied.
The thing is, if I run cp and all files are copied, its exit code ...
0
votes
1
answer
111
views
Why I can do a wildcard copy from one location, but can't from another?
One wildcard batch copy works for me:
sudo cp /home/jenkins/dist/*.war /opt/tomcat/webapps/
but another similar doesn't:
sudo cp /opt/tomcat/webapps/*.war /home/jenkins/archive
cp: cannot stat '/opt/...
0
votes
1
answer
1k
views
Rsync : Preserve date after copying
I have an issue with files attributes since I changed my company's file system from an old ubuntu 12 to a Synology NAS.
I initially mounted NFS shares on my old file system, then with cp I copied ...
-1
votes
1
answer
415
views
Safest way to move a mount point that is a parent of other mount points on Linux to a new physical device
I goofed up and /var/lib/kubelet was not mounted on a server. So it was on the root. I noticed this and I want to fix it. I did the stupid thing and just tried to stop the associated services (kubelet)...
0
votes
1
answer
3k
views
Self-Hosted Github runner, how do privileged commands work?
What I'm trying to achieve:
A fully automated deployment for a React App, on any commit to the live branch, by my own defined Github Runner, which is running Ubuntu Server 20.04, with npm 6.14.8
What ...
0
votes
2
answers
74
views
Making a copy of all .acignore->.gitignore in place, recursively
I have the following file structure as an example
c
-Git
-GitBranchTest
.acignore
[lots more files]
-subfolder
.acignore
[lots more files]
I am ...
0
votes
1
answer
2k
views
using find, exec and cp to copy specific files while preserving directory path
I set up the following folders with empty text files:
1/a.txt
2/b.txt
I want to copy only txt files to another directory while maintaining their directory structure. So I tried the following ...
0
votes
1
answer
90
views
Why nginx give different results with files whose same file-system Permission?
Every time if I put a file into the doc dir of nginx by using the mv command, it always results in a 403 Forbidden error, but if I do that by using the cp command, no error occurs.
I tried very large ...
1
vote
3
answers
162
views
How to move and partially rename files on linux
I have versioned files which come out of a build pipeline.
foo-1.3.4.war
and I need to move these files to have the name
foo-dev-1.3.4.war
How would I go about this?
I was thinking something ...
1
vote
1
answer
2k
views
UNIX Copy/Move files in same directory preserving timestamp
Following is the scenario. There are multiple files in a directory created by users belonging to same unix group.
Unix Group: Prod.
User in Prod Unix Group: User1 User2 User3.
All 3 users have same ...
0
votes
0
answers
3k
views
aws s3 cp 'Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')
I am actually writing a simple script to zip a local game save then upload the zip file into my s3 bucket.
Somehow it gives me this error though.
The most I can find googling around is about filesize ...
0
votes
2
answers
573
views
Copying files in Linux keeps full path
I made a script to, every 6 hours, copy a folder to a backup folder, then put them in /var/www/html/backup/.
My command to copy the files was cp -vR ~/world ~/backups/Backup\ on\ $date/world
My ...
0
votes
1
answer
105
views
How to escape all file names in big directory copy with cp?
I'm trying to copy an archive of user data in a folder from one disk over to another for our new NAS system using
cp -r dev-disk-by-label-MainAllData/ /root/backup/
but am getting many 'Invalid ...
2
votes
0
answers
56
views
'reboot' command doesn't work properly after 'cp' command, 'mv' behaves weird, as well
I have compiled C code running as a binary on an ARM. The ARM boots Linux from an SD Card using an old Image that was generated using buildroot. Within the C code I call a shell script that moves the ...
1
vote
2
answers
2k
views
what is the best approach to copy /var content
we have linux redhar 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/mapper/...
0
votes
2
answers
234
views
Create copy of file in the same location
I often need to create copy of files in varios locations(, and want to avoid excessive typing). (Then I will edit them)
Basically commands are like:
cp very/long/path/to/file/my-file_with-long.name ...
2
votes
1
answer
707
views
cp is too slow, same with rsync (I assume) - is there a way to share files in two locations?
I am using Docker and Docker cannot COPY symlinked files into the image. But the files that are symlinked are not in the 'build context'. So I was going to copy them into the build context with cp, ...
0
votes
1
answer
2k
views
Copy files from /var/www/html while they are used by nginx
I have a lot of data in /var/www/html.
It's more than 2GB.
Now I have the possibility to host the website on the host (nginx is using /var/www/html) or I can use docker.
For the user of docker I am ...
0
votes
1
answer
1k
views
Is it OK to copy files installed with rpm to another location?
I have a script I'm using to install some rpms in my docker image which is shown below.
yumdownloader common-jars-${RELEASE_VERSION} \
test-jars-${RELEASE_VERSION} \
rpm -ivh --force --...
0
votes
0
answers
82
views
linux copy directory over another directory and if the same rename older files appending the modification date-time
In Linux, I am wondering how one can copy (maybe some sort of merge) one directory over the second directory - which can have the same name - and if two file have the same name then rename whichever ...
4
votes
1
answer
4k
views
mv fails but cp succeeds on nfs mount
I am trying to move a file from a local directory to an nfs mounted directory on a CentOS 7 server. The export is provided by FreeNAS.
Both directories are owned by the current user with at least 755 ...
0
votes
1
answer
870
views
ACL mask not updated when cp a directory with g=r-x to directory with default:mask::rwx and default:group::rwx
I want to create a directory, in which all files are read/writeable by a specific set of users. This should work for new files/dirs in this directory, as well as for files/dirs copied to this ...
-1
votes
3
answers
152
views
copy files, get file names from a list
I am using a command:
xargs -a file_list.txt cp -t /path/to/dest
but the filenames with whitespace get cut and therefore are not copied.
what can be done?
2
votes
0
answers
783
views
RHEL 6.7 cache causing out of memory errors
I have a (large) system that has cache behavior that I don't understand. It seems that the cache ran the system out of memory. How is this possible? Doesn't the kernel clean up the cache when there'...
2
votes
2
answers
229
views
Copying between lzo compressed BtrFS's: de/re-compressing?
I'm copying a large number of files between two lzo compressed BtrFS filesystems on different drives mounted on the same machine. It appears that the files are being de/re-compressed. Is there a way ...
1
vote
2
answers
968
views
Most side effect-free way to archive a large file while it is being modified
I am looking after an application that generates a large amount of data in a log file (about 5G a day) on a Red Hat server. This process runs for 24 hours during the week, so there is no point in the ...
14
votes
2
answers
20k
views
cp -p will preserve times for some files but not all?
I have a source directory on a machine with a bunch of files, all with the same permissions, that I want to copy to another directory, that is mounted via SMB.
[tmark@dexter JR09141045 ...
2
votes
2
answers
13k
views
How to cp only into the latest directory name?
mkdir test_dir test_dir1 test_dir2 test_dir3
touch file1 file2 file3
cp -v file* test_dir*/
This copies only to test_dir3 and not in test_dir, test_dir1, test_dir2. Why?
For that matter it copies ...
0
votes
2
answers
116
views
SecAst: Potential documentation issue, Ubutunu 12.04.4 LTS and the command: cp -v
To Generation D:
I am writing you about what might just be a documentation issue which hopefully doesn't have significant repercussions.
This is something I encountered immediately at the start on ...
1
vote
1
answer
2k
views
nfs file transfers fail, "cp: cannot stat 'dir_name': No such file or directory" but sshfs works fine
We have a strange issue on our file server (Debian Wheezy 32-bit), where some files within folders contained in an nfs share fail during transfer using the cp command. Howerver, if we mount the same ...
2
votes
1
answer
4k
views
/bin/sh: /bin/cp: Argument list too long
I have problem with this command:
'cp' -fr /www/*-aws/* /www/mainhost/aws/awstatstotals/tmp/
Error is Argument list too long - I know many /www/-aws/ folders. I know that I can use FIND command, ...
0
votes
3
answers
512
views
How can I copy all files in one tree to another tree except those matching a pattern?
I have a directory tree under ./src/
I have another matching directory tree under ./work/
I'm trying to copy all the files in src to work, while keeping the directory structure and excluding all ...
0
votes
1
answer
760
views
Linux cp with gzip and numbered backup in one step?
I'm wanting to copy a file and gzip it in a single command/step
But I want to do numbered backup if the file already exists i.e. "cp --backup=numbered" or similar.
The reason for the single step is ...
0
votes
1
answer
631
views
Rotating Backups with RSync and CP - Excludes not working perfectly
My script looks essentially like this:
cp -al $yesterdays_snapshot $todays_snapshot
rsync -vadlH --exclude-from excludes.rsyc $source $todays_snapshot
This works great except for one problem:
If ...
0
votes
3
answers
653
views
Copy latest created directory
I would like to make a second backup from the latest created backup. So I tried the shell command:
last='ls -tr | tail -1'
cp -r /path/.../"$last" /path/.../backup/
but it copies a randome backup.
...
-1
votes
3
answers
931
views
CP command making recursive directories [closed]
Okay so what I'm trying to do is that I have a file and I have to replace about 100 files in the location: /home/*/service*/files/ using that file recursively.
I used the following command:
cp -r ...
2
votes
1
answer
310
views
RSYNC Slow / Copy only changed files?
I have a server that maintains thousands of log files that are nested in thousands of directories. At the moment, I am using RSYNC to copy those log files to a web server where I parse them and make ...
3
votes
1
answer
3k
views
Improve RSYNC scan speed / Alternate approach?
I'm using rsync to transfer application log files from one server to another. It works fine with the exception that scanning the directories takes forever. I have around 160,000 log files and a few ...
2
votes
2
answers
756
views
Copy entire filesystem in a folder where a raid-1 array is mounted
I am trying to migrate from a single disk drive system to a double disk drive software raid-1 system that already has a running system on it. Meaning that formatting and having a new installation of ...
2
votes
2
answers
18k
views
Linux Shell - How to copy directory without symlink
I would like to get everything inside one directory.
How can I copy entire directory (that originally contains files and symlinks) to a new directory that should contains all files but no symlink??
...
29
votes
1
answer
41k
views
SFTP: file symlinks in a jailed (chrooted) directory
I'm trying to set up sftp so that a few trusted people can access/edit/create some files. I have jailed a user into their home directory (/home/name) but have run into a problem. I want for them to ...
2
votes
1
answer
5k
views
copy and replace to folders to another fastest way - linux bash
I have a three folders: core, project and merge with many files inside.
I want to delete all files and folders (including dot files) inside the merge folder, and then copy all files (including dot ...
0
votes
1
answer
2k
views
file copy error from system to cifs mount
When coping a file greater than 64kB from an Ubuntu server to a CIFS mounted windows share, most of the data is copied, but it seems the last chunk doesn't get copied. The size doesn't match, and the ...
12
votes
3
answers
14k
views
cp command, ignore unchanged files
Is there a way to do a cp but ignoring any files that may already exist at the destination that aren't any older then those files at source.
Basically I want to copy the contents of one disk to ...
44
votes
2
answers
127k
views
preserve permission with scp
SCP does not seem to preserve ownership stamps even if used with -p option.
scp -p /mysql/serv/data_summary.* some_server:/mysql/test/
The files are owned by mysql and I want the same ownership to ...
1
vote
1
answer
376
views
Replacing directories that are subversion-monitored
We're trying to update an installed software which we have under control by subversion. The update instructions for the software require replacing several directories that have .svn directories in ...
4
votes
1
answer
7k
views
What does the message, "too many links" mean when using CP on Linux?
I am copying 25,000 folders containing hundreds of files each from one hard drive to another on the same Linux server. The destination folder already contains 25,000 different folders full of their ...
7
votes
2
answers
26k
views
What's faster for copying files from one drive to another? [closed]
Running linux. I have two identical drives mounted on the same machine. What is faster CP, MV, or RSYNC? Why is one faster than the other? Are there any faster alternatives?
1
vote
1
answer
478
views
Does cp -p apply to the source or destination file?
When I use -p to preserve the file permissions of a file being copied, does it apply to the source or the destination file (if it already exists)?
Thanks
1
vote
3
answers
6k
views
Estimating the time needed to copy a big file
I have to copy a relatively big file (6GB) to another server. To enforce consistency, I have to 'lock' this file and not use it during the transfer. I obviously want to minimize this downtime, but ...