LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp and symbolic links? (https://www.linuxquestions.org/questions/linux-general-1/cp-and-symbolic-links-344437/)

sausagejohnson 07-18-2005 06:46 PM

cp and symbolic links?
 
Noticed a difference in behaviour between fedora and gentoo using the cp command over symbolic links and hoping someone can explain why...

My /etc/localtime file is a symbolic link back to --> /usr/share/zoneinfo/Australia/Sydney

In the two operating systems, I issue a: cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime

FEDORA:
The Adelaide file overwrites the localtime file.

GENTOO:
The Adelaide file overwrites the file that /etc/localtime is pointing to, in this case, /usr/share/zoneinfo/Australia/Sydney becomes a copy of Adelaide.

Can anyone explain why and tell me what switches I need that will force an overwrite, deleteing the old symbolic link and writing Sydney as the new /etc/localtime file (no longer being a symbolic link)?

mhallbiai 07-19-2005 12:55 AM

to see what switches are used (FC) type: alias
and compare to gentoo

hope this helps

sausagejohnson 07-19-2005 01:17 AM

Ah........ reveals some info. Thank you.

Fedora has cp as 'cp -i'
Gentoo has nothing

To me this means the only difference is that Fedora will force you to select (Y/N) to an overwrite.

Other than that, the behaviour should not be different. Handy util though.

mhallbiai 07-19-2005 01:25 AM

i have no experience with gentoo other than watching friends start the compile...

there is a -d switch in 'man cp' which says:
Quote:

-d same as --no-dereference --preserve=link
--no-dereference
never follow symbolic links
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps) and security contexts, if possible additional attributes:
links, all
so maybe trying: cp -d /usr/share/zoneinfo/Australia/Adelaide /etc/localtime

hope this helps


All times are GMT -5. The time now is 01:23 AM.