Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-05-2006, 09:38 AM   #1
LQ Newbie
Registered: Aug 2004
Distribution: Redhat Enterprise
Posts: 15

Rep: Reputation: 0
Changing a soft link to actual file?

This is actually on OS X, but I figured the CLI tools are (more or less) the same.

I have a directory(webserver documents) that has several levels of subdirectories inside it. A number of the files in these directories are soft links.

The real files actually exist in my home directory. I want to move these files out of my home directory and into the webserver's documents directory. AKA replace the soft links with the actual file.

If I try to copy the file on top of the soft link, I get a "cp: ./BLP_Head_1.JPG and /Users/jacob/images/BLP_Head_16May2005/BLP_Head_1.JPG are identical (not copied)." error.

I'm running the Gallery2 program, which provides an image gallery and allows the user to move files/albums around. Therefore, the directory structure of the links and the files differ, so I can't simply remove the links and copy the files over.

Is there an easy way to change the soft links into actual files? Or change them into hard links, so I can remove the files from the home directory and effectively do the same thing?

Old 04-05-2006, 11:02 AM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
What probably happened when you tried to copy the files "on top of the soft link" as you said was that it tried copied the original file, and then tried to paste it to the same place - the copy tool followed the link in both of the situations, in copying and pasting. What you would have wanted to, I guess, was to copy the file to which the link points and paste it to the other directory, not the one where the link points. If you use that approach, you'd need to tell the copy tool not to follow the my opinion it's the same operation, though, as if you would delete the links and simply copy the original files to their place (=overwrite the links with the original files).

I'm not a master but I'd see the easiest way is to simply delete the links and copy/move the original files to their place and then deal with the gallery program (rebuild an index or something..I haven't used too many of those).
Old 04-05-2006, 11:15 AM   #3
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
cp  --remove-destination ...
Old 04-05-2006, 11:26 AM   #4
LQ Newbie
Registered: Aug 2004
Distribution: Redhat Enterprise
Posts: 15

Original Poster
Rep: Reputation: 0
To clarify a bit:

The file exists in:


The link exists in: /Library/Webserver/Documents/tc22/g2data/albums/pics/BLP/BLP_Head_16May2005/BLP_Head_1.JPG
which points to the file above.

The command:
cp /Users/jacob/images/BLP_Head_16May2005/BLP_Head_1.JPG Library/WebServer/Documents/tc22/g2data/albums/pics/BLP/BLP_Head_16May2005/BLP_Head_1.JPG

fails with :
cp: /Library/WebServer/Documents/tc22/g2data/albums/pics/BLP/BLP_Head_16May2005/BLP_Head_1.JPG and /Users/jacob/images/BLP_Head_16May2005/BLP_Head_1.JPG are identical (not copied).

I also tried with the -f flag, same results.

It does look like cp is following the link for the destination, and OS X's cp doesn't see to have a --no-dereference option.

The gallery2 program I'm using uses mysql to handle all the stuff, so I think if I manually move files around the filesystem it would pretty much blow away the gallery. Having to recreate the gallery would be an extremely non-trivial task
Old 04-05-2006, 11:45 AM   #5
LQ Newbie
Registered: Aug 2004
Distribution: Redhat Enterprise
Posts: 15

Original Poster
Rep: Reputation: 0
Looks like I can just use ln -f and it will recreate the file as a hardlink. Then I can just fix the permissions (so www is the owner), and remove the files from my home directory.

Thanks for the help.


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
Difference Between Soft Link & Hard Link rajaniyer123 Solaris / OpenSolaris 16 09-30-2012 03:42 AM
copy both soft link and its linked file okeyla Programming 3 02-13-2005 11:30 PM
how to create link into actual file? elmerliu Linux - Newbie 11 08-15-2004 11:40 AM
how to create a link into actual file? elmerliu Fedora 1 08-14-2004 08:56 AM
changing permissions on a soft link jse580 Linux - Networking 2 03-02-2004 03:48 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:25 PM.

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