Copying symbolic links

Linux, BSD, UNIX and all other operating systems not covered in other sub-forums.

Moderators: Edward, jubalj, Pu7o

Copying symbolic links

Postby Edward » Tue 28 Oct, 2003 9:40 pm

I learned something tonight.

I decided to install Mozilla 1.5 on the Linux box, as I have been coming across an increasing number of sites that will not display properly with Netscape 7.1, but the same pages display fine with Mozilla 1.5.

As Mozilla is in its own separate directory, it did not use the same plugins that Netscape uses. Rather than recreate new symbolic links in the Mozilla plugins directory, I copied/pasted them using Konqueror, and much to my surprise, they worked.

I didn't think a symbolic link could be copied, but I guess we all learn something new every day. :)
UserAgent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.5) Gecko/20031007
SillyDog701 Moderator
debian 6 - iceape - iceweasel - icedove - seamonkey
User avatar
Edward
Moderator
Moderator
 
Posts: 3584
Joined: Sun 01 Dec, 2002 7:15 pm

might not work so well on relative soft links

Postby jubalj » Sat 01 Nov, 2003 1:30 am

(a quick post for the benefit of linux newbies)

yup no problems copying symlinks (aka softlinks or symbolic links), but remember there are two types of symlinks- absolute and relative. Intutively, absolute ones have the full path to the file and begin with '/'. Relative links can be broken when they are copied, so watch out.

heres a bit of code to explain things:
bash-2.05b$ date >date.txt <-- creating a sample text file
bash-2.05b$ ls
date.txt
bash-2.05b$ ln -s date.txt daterel.txt <-- creating symlink
bash-2.05b$ pwd <-- simple command to show the working dir
/home/jubalj/test
bash-2.05b$ ln -s /home/jubalj/test/date.txt dateabs.txt <-- creating the absolute symbolic link
bash-2.05b$ ls -l
total 5
-rw-r--r-- 1 jubalj users 14 Nov 1 19:09 date.txt
lrwxrwxrwx 1 jubalj users 26 Nov 1 19:24 dateabs.txt -> /home/jubalj/test/date.txt
lrwxrwxrwx 1 jubalj users 8 Nov 1 19:22 daterel.txt -> date.txt

basically if you copied dateabs.txt anywhere.. it would still work.. but if you copied daterel.txt it wont! But note that the default behaviour of the 'cp' command is to copy the actualy file not the link (which kinda means stuff still works).. ie:
bash-2.05b$ cp daterel.txt newdate.txt
bash-2.05b$ ls -l
total 9
-rw-r--r-- 1 jubalj users 30 Nov 1 19:24 date.txt
lrwxrwxrwx 1 jubalj users 26 Nov 1 19:24 dateabs.txt -> /home/jubalj/test/date.txt
lrwxrwxrwx 1 jubalj users 8 Nov 1 19:22 daterel.txt -> date.txt
-rw-r--r-- 1 jubalj users 30 Nov 1 19:28 newdate.txt

so newdate.txt is a file and not a link.

Jubal

Edit:did it in a hurry earlier so i've annotated it a bit..hope it makes more sense.
UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031019
jubalj
Moderator
Moderator
 
Posts: 23
Joined: Tue 29 Jul, 2003 10:14 pm
Location: Auckland, NZ


Return to Linux and Other OSes

Who is online

Registered users: Google [Bot], Yahoo [Bot]