Questions tagged [cp]

Questions relating to the Linux 'cp' command.

Filter by
Sorted by
Tagged with
0 votes
0 answers
42 views

Why do cp, and nocache cp, clog up and slow down/freeze after 2-4 TB, but rsync is effective indefinitely?

Is there a setting I'm missing in CP and nocache CP that frees up resources after each file? I looked around, and read that cp and nocache cp are MUCH faster, and use more RAM instead of CPU, but not ...
Kmaws's user avatar
  • 1
0 votes
0 answers
58 views

preserve=timestamps is not permitted

I use --preserve=timestamps when I copy a file. This worked under Ubuntu 20.04, but running 22.04 I get: cp: preserving times for '/d/news/2024-01-04.COA DEMS - Mazars Report.pdf': Operation not ...
nil's user avatar
  • 1
0 votes
0 answers
25 views

cp to a previous directory using the shortcut - [duplicate]

I am a beginner with Ubuntu and I tried searching for an answer for this but I can't find one that covers this and I am confused by the output I am getting. I know you can use cp to copy to a parent ...
Dean Cole's user avatar
0 votes
0 answers
235 views

Copy files from a list with spaces in the names to a new destination in Ubuntu

so i have an mp3 playlist (playlist.txt): /home/ME/music/These guys/The first dumb track.mp3 /home/ME/music/Band two/my fav track04.mp3 /home/ME/music/Some other weirdos/The third One.mp3 obviously ...
Skarecrow's user avatar
-1 votes
1 answer
474 views

How to copy ONLY parent folder with find and CP?

Why does the following command copy the DCIM folder and it's subfolders and files..I just want the DCIM folder to be copied. find ./"DCIM" -name "DCIM" -maxdepth 0 -type d -exec cp ...
ghostanime2001's user avatar
0 votes
1 answer
81 views

Having trouble moving symlinks from backup to boot partition

The context I have a dual-boot Ubuntu (Jammy Jellfish)/Windows laptop (Dell XPS 9550). My /boot partition was too small to support an update, so I used GParted to attempt to resize it. However, I ...
Alexander Nied's user avatar
0 votes
1 answer
160 views

How to fix this error in cp?

#!/bin/bash SrcDir=$1 DstDir=$2 #If DstDir is not exist, this creats it if ! [ -a $DstDir ]; then mkdir $DstDir fi #Formats Vformat=(mp4 avi 3gp mpeg mkv wmv mov) Iformat=(jpg jpeg png) Year(){...
UnitedKingdom's user avatar
1 vote
1 answer
2k views

How to best copy large folders?

I want to copy 1 TB of data from 1 HDD to another via Terminal. What is the best approach to this? So far, i've used the following, but I've no idea, whether it actually makes progress, or if it just ...
Tasmotanizer's user avatar
0 votes
2 answers
572 views

How can we copy a file to all subdirectories using cp and wildcard

Let's say I have 10 subdirectories in a main-directory named d1, d2, d3, ..., d10. How can I copy a file into all these subdirectories using cp? I'm looking for something like cp ./my_file.txt ./d*/
brownser's user avatar
  • 153
1 vote
1 answer
4k views

Anyway to undo overwriting file by mv or recover replaced file?

I accidentally mv a new file to an existing file and overwrote it. Is there anyway to undo mv or recover the replaced file?
user42's user avatar
  • 11
1 vote
1 answer
427 views

Having trouble copying conda environment folder containing same word (different case) files with symbolic links in terminfo subdirectory

I am using WSL1. I am trying to save a copy of my ~./miniconda/envs folder to the desktop using cp. I keep getting errors like cp: cannot create regular file './envs/py_env/share/terminfo/h/hp2621a':...
Elijah's user avatar
  • 111
-4 votes
1 answer
145 views

Copy some files from source directory A to directory B and some files to Directory C with non sequential order

I am looking for a script to copy files from a source directory to two destination directories with non sequential order. For instance I want to copy some files from source directory A/ to destination ...
sunman's user avatar
  • 43
0 votes
2 answers
39 views

Copying a downloaded file into my current terminal folder

I am compiling WRF on my HP Desktop. I'm in Ubuntu terminal and trying to use the cp command to copy from my D Drive, but it just won't work. Using cp D:\MyWRF/file.tar . All I get is cannot stat, ...
John Hurley's user avatar
0 votes
1 answer
1k views

Copying file with the same name from different directories to the directory before

I have a set of 120 files, all with the same name,contig.fa which are located in the hierarchy of Main Directory 1 Subdirectory 1 file.fa Main Directory 2 Subdirectory 2 file.fa I ...
veridian21's user avatar
7 votes
1 answer
2k views

Why does "cp" complain about identical files when chaining with "find"?

I have a find command as below that lists the matching files: $ find . -type f -name "*.txt" ./level2/file2.txt ./level2/level3/file3.txt ./level2/level3/level4/file4.txt ./level2/level3/...
Isaac's user avatar
  • 173
0 votes
0 answers
550 views

cannot paste external files into a ntfs file system in Ubuntu 20.04.4

on Ubuntu 20.04.4 LTS I have an NTFS data partition. This is a dual boot system with Windows 10. The option "paste" is grayed out when I try to copy-paste into the NTFS partition any file ...
Cristiano's user avatar
  • 243
0 votes
1 answer
24 views

Link directory to another directory to ccopy files

I have a folder: /share/public I am working in the folder: /home/john/workingfolder It means that currently I am in the "workingfolder". I would like to send files to /share/public but ...
Carlitos_30's user avatar
0 votes
1 answer
102 views

How do I copy a local home dir to an iscsi mounted home directory

I have various Ubuntu images on this machine, each with their own home dir. I am trying to consolidate them on a redundant iscsi NAS. This seems like it should be straight forward. It eventually locks ...
Walt Corey's user avatar
4 votes
2 answers
4k views

Make multiple copies of one file with different names

How can I create multiple file from one? Like, I have 1.json, but want to create 2.json + 3.json + 4.json out of it. Most obvious way is to just cp 1.json 2.json and so on; but does Linux provide some ...
E1dar's user avatar
  • 151
0 votes
0 answers
623 views

unable to copy files from ssd to hdd in ubuntu 20.04

I'm trying to copy media files like .mp3,.mp4, .mkv etc. from my ssd to hdd as to save time complexity of ssd but unable to do so. Everytime I try to copy or move files it shows me this error "...
Naeem Navjivan's user avatar
0 votes
1 answer
3k views

Why doesn't 'sudo cp' copy files in the /sys directory?

I want to make an exact copy of the /sys directory, and tried the following command: sudo cp -ra /sys ~/Documents/dir1 It does not work as I expected... I get a lot of error messages such as: cp: ...
rapt's user avatar
  • 520
1 vote
1 answer
199 views

How to automatically open a file that has a dynamic filename

I'm trying to make an automation process, my workflow generates a file automatically, this file is named based on a timestamp and a public key. Example of the file name : UTC--2022-03-07T10-53-08....
EL-Mehdi Loukach's user avatar
0 votes
1 answer
297 views

Is there an easy convertor between dpkg --print-architecture and uname -m for generic scp?

I want to copy files that relevant to my machines (x86_64 / aarch64) from remote machines. I want to use: scp user@host:*$(uname)* . to copy both wheels and .deb files, e.g.: name-x.y.z-cp36-cp36m-...
CIsForCookies's user avatar
0 votes
2 answers
3k views

Copy all from a folder into the project root directory

I have a web project with the following structure: application/ dumps/ nginx/ logs/ .git/ docker-compose.yml Dockerfile README.md .gitignore For several reasons, I would like to dissolve the ...
Maik Lowrey's user avatar
0 votes
1 answer
86 views

How to move a matched id of mat files in different folder

I have Matlab (.mat) files in a particular folder. In a text document, I have some IDs list marked as 0 and 1. First I need to match the IDs and separate the mat files that are marked as '1'. For your ...
Jammy's user avatar
  • 1
0 votes
1 answer
392 views

Accidentally used "cp /file /dev/sdb1"

I'm about to cry, in need of your help... I'm new to linux. I was trying to copy a Windows10 iso to my external HDD. I wanted to use cp command. I saw that my external HDD was sdb1. So I just used cp /...
lemnlover's user avatar
0 votes
1 answer
1k views

How to copy multiple files to a new folder in a new path in one command?

[These are the files I want to copy over][1] Example command I have tried but does not work: cp permanent_waiver_* /existingpath/newfolder1/newfolder2 This would give me error like no such file or ...
Min's user avatar
  • 1
0 votes
2 answers
1k views

Copy files based on date with structure of directories

I have commend: find /source/ -type f -newermt '18 dec 2020' -exec cp -t /target/ {} + This commend copy only files, without structure of dirs, but i need files with his parent dir. Second thing is ...
mechmati's user avatar
0 votes
2 answers
147 views

How to copy files into a new file

How to copy files from one file to another file that has contents I want to keep? In other words, I want the contents of file1 to go in file2 but the info in file1 to be added to the existing stuff in ...
Elon_s_mom's user avatar
0 votes
1 answer
1k views

I would like to maintain a mirror copy of many files and directories using cp, but I cannot get it to function (similar to MS XCOPY with switches)

I am trying to copy SOURCE to DESTINATION, so that DESTINATION is identical to SOURCE. Note that SOURCE is 89GB with 26k files and hundreds of folders, so it is not practical to do an entire copy when ...
Kevin Paul's user avatar
1 vote
1 answer
274 views

Rename file names with a parent directory name

I want to rename my files recursively, ending with *.fna.gz with the parent directory two-step-up i.e. "Aspergillus_neoniger". You can see the subdirectories details in this image tree ...
shahzad's user avatar
  • 43
1 vote
2 answers
3k views

Way to speed up cp -a (using cp -a within a thumb drive is very slow)

When using a thumb drive with a persistent operating system, it happens that the persistent partition casper-rw gets corrupted, if one pulls out the thumb drive too early after shutting down the ...
Adalbert Hanßen's user avatar
2 votes
2 answers
381 views

Move all JPGs and rename them into one directory

.Hi. I have a bunch of jpgs in 100s of subfolders , I know I can move them all with this command find -type f -iname "*.jpg" -exec mv -av {} /home/root/private/pics/ \; But my all my jpgs ...
1014Noob's user avatar
0 votes
0 answers
801 views

cp: cannot stat '{1..112046}.pth': No such file or directory

I am using Ubuntu 16.04. I am trying to copy the range of files from one directory to another directory. cp {1..112046}.pth path/to/destination_folder While being inside the source folder. But it ...
Imaq_fa's user avatar
2 votes
1 answer
143 views

cp .* /home/name erased all files in /home/name

A while ago, I got a new ssd for my laptop, so I dd'd everything onto the new drive, and used it for a while without issue. I decided to put the old drive back into my laptop, and put newer ssd into a ...
ruinedanothergoodinstall's user avatar
1 vote
0 answers
750 views

Problems copying to SD card

I am trying to automate copying a large file (25MB +) to an SD card, but it's not working - So I've tried in the command line... cp /tmp/MIRROR/myfile.db /run/media/mmcblk0p1/MIRROR/ but this throws ...
komodosp's user avatar
  • 111
0 votes
1 answer
547 views

Stop `cp -al` trying to link to hidden files?

I would like to make a "hard-links" copy of my home directory before syncing my home directory with another computer with unison, just in case unison goes awry. But cp -al tries to link to ...
B.Tanner's user avatar
  • 2,636
1 vote
1 answer
124 views

why doesnt this bash script get all the files?

I have a large folder with subfolders of pdf files. I want to get all the pdf files (290 of them) and get them into one directory. (I thought that would be simple.) so that I can concatenate them into ...
j0h's user avatar
  • 14.8k
-3 votes
1 answer
176 views

How can I copy a file n Linux terminal, without pasting it? [closed]

I have run this in my Linux machine # cp file . Is that command copying file1? Is there anyway to paste file1 in other folder after using above command (whitout cp file1 path/to/file)?
Antonio Sanchez's user avatar
8 votes
2 answers
4k views

cp recursive with specific file extension

I am trying to copy all .odt files including those in subdirectories. cp -r ~/Documents/* ~/copies # works as expected cp -r ~/Documents/*.odt ~/copies # does not work as expected The first line ...
Insideup's user avatar
  • 115
3 votes
3 answers
5k views

Copy files and set owner/group to the owner/group of the destination directory

I have a script used in different environments. This scripts uses sudo cp to copy files (sudo otherwise it has no access). But sudo cp creates the files with the wrong owner. It cannot keep the owner ...
R. Oosterholt's user avatar
0 votes
1 answer
2k views

sudo: unknown uid 1000: who are you? (sudo completely broken)

I am new to Linux environment and I need little guidance. I made a mistake while setting up the password and username of mosquito MQTT broker on AWS ubuntu 18.04 instance. I have altered the contents ...
chaya kumar's user avatar
1 vote
2 answers
558 views

How to copy files with certain permissions to directory

I'm trying to make a copy of files with read and write permissions for the owner only, and then redirect that file to a directory named $dirA. I tried to use this command: cp (ls -l ~| grep -type f-...
Salma Jaoua Kechaou's user avatar
0 votes
1 answer
583 views

What is cp command with tilde in final part of destination? [duplicate]

For example: sudo cp /etc/apt/sources.list /etc/apt/sources.list~ With this command I not see any changes. What does the final tilde do?
Mario Palumbo's user avatar
0 votes
0 answers
25 views

TAB does't work properly with `cp` command when using environment variables [duplicate]

Question When using cp command with environment variables, why pressing TAB for auto-complete doesn't work properly? Description I have a directory $HOME/Music; I want to copy a file from within this ...
Naghi's user avatar
  • 157
0 votes
1 answer
3k views

Copying a .bashrc file from one user's directory to another

I am trying to copy a bashrc file from one folder to another. For example, the bashrc file is in Data/user/user1 and I am trying to copy it to Data/user/user2 with the following cp command: cp Data/...
Eliran Turgeman's user avatar
1 vote
2 answers
483 views

Need help using the SCP command line

I have a server with Ubuntu 18.04 I want to transfer my website to a new server. Here are my questions : How to copy files with png extension ? I tried the following command line but it doesn't work : ...
Mathieu's user avatar
  • 13
1 vote
1 answer
220 views

File has weird name, and cannot be found after being copied

Technically all I'm trying to do is substitute one file with another using a script: echo "PASSWORD" | sudo -S rm paper_RPG.jar cp /home/network/PaperAndWaterfallUpdater/paper.jar paper_RPG....
Mithrandir's user avatar
0 votes
0 answers
2k views

mv: missing destination file operand when special characters are involved [duplicate]

This one's silly. I saved my vim session with :Obsess -S Session.vim instead of :Obsess Session.vim, so now I have a -S/ Session.vim file in my project and can't open it with vim as the following is ...
arshbot's user avatar
  • 153
0 votes
1 answer
4k views

simple cp command problem " i try to copy only "

cp: 'test.txt' and 'test.txt' are the same file asadzoot@asadzoot-Vostro-14-3468:~/cnc/q1$ cp test.txt home/asadzoot/cnc/q1/ cp: cannot create regular file 'home/asadzoot/cnc/q1/': No such file or ...
Syed Asad Raza's user avatar

1
2 3 4 5