LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Symbolic Links (https://www.linuxquestions.org/questions/linux-newbie-8/symbolic-links-179877/)

Greg_courageous 05-10-2004 07:03 AM

Symbolic Links
 
Hey everyone, i have a question that has been bugging me, someone might be able to help...

I know how the commands rm and ls work on ordinary files. but i want to know how the work on symbolic links.
Does a symbolic link point to an existing file???
What happens if the actual file of a symbolic link is deleted? Is it possible for a symbolic link to point to another symbolic link?

if anyone knows much about them any help would be greatly appreciated!
Thanks!
Greg

robkg 05-10-2004 08:05 AM

ls can also list symbolic links;

tosca~$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 36 Apr 10 19:44 /etc/localtime -> /usr/share/zoneinfo/Europe/Amsterdam
tosca~$

rm by default does only remove the symlink, not the file that it is pointing to. However when you read or write to a symbol link, it will write the contents to the file that the symlink points to.
When you remove the target file which the symlink is pointing to, the symlink does not disappear, because the target file does not keep information about which symlinks point to it. You can just remove a symlink that points to a non-existing file.
If you try to read from it, it just says the file does not exist.
symlinks can point to other links, but i believe that there is a limit to the ammount of links they point to.
Try this:

$ ln -s a b
$ ln -s b a
$ cat a
cat: a: Too many levels of symbolic links
$

Hope it was helpful


All times are GMT -5. The time now is 10:30 AM.