LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Small question about /etc/rc.local - Symbolic link question (https://www.linuxquestions.org/questions/linux-general-1/small-question-about-etc-rc-local-symbolic-link-question-444263/)

Arodef 05-12-2006 08:35 PM

Small question about /etc/rc.local - Symbolic link question
 
I was playing around with some run-once startup scripts and I noticed /etc/rc.local links to rc.d/rc.local:

lrwxrwxrwx 1 root root 13 Jun 11 2004 /etc/rc.local -> rc.d/rc.local


As you can see this linking works without the full path to the file: /etc/rc.d/rc.local. I did some experimenting and found it will still point to the that file whether you do:

ln -s /etc/rc.d/rc.local /etc/rc.local
or
ln -s rc.d/rc.local /etc/rc.local

My question is how does the system know how to point /etc/rc.local to /etc/rc.d/rc.local when it doesn't have the full path to it? Just curious. Thanks!

perfect_circle 05-12-2006 08:40 PM

did you execute "ln -s rc.d/rc.local /etc/rc.local" from /etc?

rc.d/rc.local means the file rc.local which is in the directory rc.d which is under the current directory.

Arodef 05-12-2006 08:44 PM

Nope, I did the linking from /root. The system still figures out to point rc.d/rc.local to /etc/rc.d/rc.local from /root. Can you try it on your system?

perfect_circle 05-12-2006 09:06 PM

Actually I think it has to do with how the links work.

It just creates a link somewhere with a path:

It creates the link rc.local in /etc with path to rc.d/rc.local.

You don't specify the full path so it just creates a link pointing at the relevant path rc.d/rc.local.

Since the link is in /etc the full path for the relevant one IS /etc/rc.d/rc.local.

A link just saves a path. Nothing less and nothing more. The path can be relevant or full.

The same happens with every link:
Code:

root@darkstar:/home/skalkoto# ln -s workspace/hello ~/rc.local
root@darkstar:/home/skalkoto# cd ~
root@darkstar:~# ls -l rc.local
lrwxrwxrwx 1 root root 15 2006-05-13 05:10 rc.local -> workspace/hello/
root@darkstar:~#


Arodef 05-13-2006 02:29 AM

Ahhh, ic. Thanks for the explanation!


All times are GMT -5. The time now is 10:19 PM.