You can use cp -f or –force option to forcefully copy and replace the destination file if the destination file cannot be opened (redundant if the -n option is used).
1 2 3 4 5 6 7 8 |
mkdir mydir ## create some files and directories touch myfile mydir/myfile chmod 444 mydir/myfile ## change the file permission cp myfile mydir ## error, Permission denied cp -f myfile mydir ## successfull rm -r my* |