LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2005, 03:36 PM   #1
R4z0r
Member
 
Registered: Jan 2002
Distribution: CentOS 3.1
Posts: 119

Rep: Reputation: 15
Hop to force a "cp" ??


Hey all, I know this is a simple quesiton but for some reason I can't get "cp" to replace files without prompting!

Example:

Code:
# cp -arf /media/cdrecorder/RedHat/ /mnt/inst
cp: overwrite `/mnt/inst/RedHat/RPMS/amanda-2.4.4p1-0.3E.i386.rpm'?
I thought "-f" forced so it wouldn't ask for confirmation, can someone advise what I am doing wrong?

Thanks
 
Old 04-20-2005, 03:41 PM   #2
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
You probably don't own the file you're trying to overwrite. If you don't own the file, either become the person who does or root ( which is probably who owns it ).

The other possibility since you're trying to copy to a /mnt type deal, you might not have mounted the partition in a write mode.
 
Old 04-20-2005, 03:54 PM   #3
R4z0r
Member
 
Registered: Jan 2002
Distribution: CentOS 3.1
Posts: 119

Original Poster
Rep: Reputation: 15
Thanks, but I am already root and I do have write access to that directory.

Code:
[root@pandora inst]# pwd
/mnt/inst
[root@pandora inst]# touch something
[root@pandora inst]# ls
RedHat  something
I was trying to export it via NFS but have stopped the NFS service and now it's not exported at all yet still keeps prompting me if I want to overwrite.

Code:
[root@pandora mnt]# showmount -e
mount clntudp_create: RPC: Program not registered
It's also not isolated to these files/directories, I tried the same thing on /tmp.

Code:
[root@pandora tmp]# mkdir garbage
[root@pandora tmp]# cp -ar * garbage/
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
[root@pandora tmp]# ls garbage/
garbage         oo
gconfd-nick     orbit-nick
gconfd-root     OSL_PIPE_500_SingleOfficeIPC_cb479e13a9743bca6ed44ec3f8a4936
keyring-HSQCEk  ssh-kvjkGe4426
keyring-MUijXD  vmware-nick
keyring-sXMfSd  vmware-root
mapping-nick    xses-nick.dSSw6O
mapping-root
[root@pandora tmp]# cp -ar * garbage/
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: cannot copy a directory, `garbage', into itself, `garbage/garbage'
cp: overwrite `garbage/gconfd-nick/lock/ior'?
cp: overwrite `garbage/keyring-HSQCEk/socket'?
cp: overwrite `garbage/keyring-MUijXD/socket'?
cp: overwrite `garbage/keyring-sXMfSd/socket'?
cp: overwrite `garbage/mapping-nick'?
cp: overwrite `garbage/mapping-root'?
cp: overwrite `garbage/orbit-nick/linc-11c1-0-4bfb9a6872815'?
cp: overwrite `garbage/orbit-nick/linc-1170-0-5e4661c163262'?
cp: overwrite `garbage/orbit-nick/linc-119f-0-37a8605bce508'?
cp: overwrite `garbage/orbit-nick/linc-1199-0-4391e1e2ee44b'?
cp: overwrite `garbage/orbit-nick/linc-11b1-0-6cea2baded9d2'?
-SNIP-

Last edited by R4z0r; 04-20-2005 at 04:01 PM.
 
Old 04-20-2005, 04:13 PM   #4
R4z0r
Member
 
Registered: Jan 2002
Distribution: CentOS 3.1
Posts: 119

Original Poster
Rep: Reputation: 15
Hmm, in the end I just used rsync which has worked a treat so deffo not a perms issue.

Would still like to know how to stop cp from promting though if anyone knows?
 
Old 04-20-2005, 06:47 PM   #5
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154

Rep: Reputation: 30
Try typing "alias" minus the ""s and see if the output is something along the lines of cp='cp -i' somewhere in there.

on your system you may have the cp command actually mean "cp -i" which causes cp to prompt even if
you only type cp.
 
Old 04-21-2005, 02:45 PM   #6
R4z0r
Member
 
Registered: Jan 2002
Distribution: CentOS 3.1
Posts: 119

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by dosnlinux
Try typing "alias" minus the ""s and see if the output is something along the lines of cp='cp -i' somewhere in there.

on your system you may have the cp command actually mean "cp -i" which causes cp to prompt even if
you only type cp.
Yup, that was it. Thanks for that.
 
Old 04-21-2005, 03:55 PM   #7
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154

Rep: Reputation: 30
Quote:
Yup, that was it. Thanks for that.
Glad I could be a help for once instead of asking for it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 05:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 12:26 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 04:07 PM
Automatically "force load " modules of PCtel modem on redhat juby Linux - Hardware 2 01-14-2003 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration