LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-02-2010, 06:19 AM   #1
spoovy
Member
 
Registered: Feb 2010
Location: London, UK
Distribution: Scientific, Ubuntu, Fedora
Posts: 373

Rep: Reputation: 43
Symlink/ link question... can someone explain please! ta


Hi

I am trying to learn linux in a bit more depth, and i'm a bit baffled by this. So if someone could answer i'd be very grateful!

On my Fedora 12 box, in a terminal, if i cd to /etc/rc3.d and list items, it lists a load of links (symlinks?) to files within /etc/init.d. If I cd to /etc/rc.d/rc3.d and list items, a load of apparently identical links (symlinks?) are listed, pointing to the same files in /etc/init.d.
OK fine, so there are two sets of links pointing to the same files.

BUT

If I cd to /etc and longlist (ls-la) the contents, then the /etc/rc3.d directory is shown as a link (symlink?) to /etc/rc.d/rc3.d.

So what is /etc/rc3.d? Is it a file full of links, or is it a link itself? Or both??

Thanks in advance

Spoov
 
Old 03-02-2010, 06:45 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by spoovy View Post
On my Fedora 12 box, in a terminal, if i cd to /etc/rc3.d and list items, it lists a load of links (symlinks?) to files within /etc/init.d. If I cd to /etc/rc.d/rc3.d and list items, a load of apparently identical links (symlinks?) are listed, pointing to the same files in /etc/init.d.
OK fine, so there are two sets of links pointing to the same files.

BUT

If I cd to /etc and longlist (ls-la) the contents, then the /etc/rc3.d directory is shown as a link (symlink?) to /etc/rc.d/rc3.d.
Depending of the way your runlevel are managed you can have a two way of structure. In generel there are two ways linux handles the starting of process after init is run. One is SysV and the other is init.d (Not sure about if init.d is the right name). As LInux developed there was a change from one of the startup logics to the other. But to remain portable the transfer was done by using both kinds of structure and just help out with symlinks.

Now to your question.
Quote:
Originally Posted by spoovy View Post
So what is /etc/rc3.d? Is it a file full of links, or is it a link itself? Or both??
/etc/rc3.d is the directory that gets scanned by init when you change the runlevel to runlevel 3.
On linux you normaly have one directory (/etc/init.d) which holds all the scripts that are used to start/stop process. The directories for the runlevel, rc3.d in your case, hold symlinks to the scripts that one wants for this certain runlevel.

And as your distribution is in the transid state it just symlinks this to the old style of startup.

Hm Hope it made some things clearer. Maybe check out this link and do a google for "linux startup" to get some further information


http://en.wikipedia.org/wiki/Linux_s..._style_only.29
 
Old 03-02-2010, 06:46 AM   #3
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
If the links are shown by ls -l, then they are symbolic links, not hard links.

When /etc/rc3.d is symbolically linked to /etc/rc.d/rc3.d, then the real directory is /etc/rc.d/rc3.d. It in turn contains a load of links. So when you cd to /etc/rc3.d, you are looking at the same links as when you cd to /etc/rc.d/rc3.d. There are only a single set of links. It is just a way to make the same files appear in multiple path locations.

Last edited by neonsignal; 03-02-2010 at 06:49 AM.
 
Old 03-02-2010, 07:17 AM   #4
spoovy
Member
 
Registered: Feb 2010
Location: London, UK
Distribution: Scientific, Ubuntu, Fedora
Posts: 373

Original Poster
Rep: Reputation: 43
Thanks guys, I think i get it. A problem with my mental model i think.

So when i cd to /etc/rc3.d, I was expecting to be actually transported to /etc/rc.d/rc3.d, when really its more like a window, so cd'ing into it I am just peering through the link to the target dir. Hence my being able to see the contents of the target directory while not actually being 'in' it.

Right??
 
Old 03-02-2010, 07:45 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
And for some more mind games....

You are never actually **in** a directory---all you are doing with "cd" is changing the value of the PWD env. variable, so that it can be used as part of a relative path. For example in your home directory, you want to read a file. When you do "cd ~" is sets PWD=/home/yourusername. Then --eg--the command "more" uses PWD to help set the path.
Thus "more filename" is really "more $PWD/filename".

If you specify an absolute path, then PWD is not used, eg:
"more /home/yourusername/filename"

Finally, when you issue "cd <something>" you will change PWD, regardless of whether <something> had a soft link in it.

BUT--if there is a soft link, then PWD becomes the link path. Therefore something like "cd .." works as expected.

Example (linktotextfiles is a soft link in ~ that points to play/textfiles):
Code:
[mherring@Ath ~]$ cd linktotextfiles
[mherring@Ath linktotextfiles]$ ls
a  b  c  ca.gz  newdir  this.gz
[mherring@Ath linktotextfiles]$ pwd
/home/mherring/linktotextfiles
[mherring@Ath linktotextfiles]$ cd ..
[mherring@Ath ~]$ cd play/textfiles
[mherring@Ath textfiles]$ ls
a  b  c  ca.gz  newdir  this.gz
[mherring@Ath textfiles]$ pwd
/home/mherring/play/textfiles
[mherring@Ath textfiles]$ cd ..
[mherring@Ath play]$
So---being "in" ~/linktotestfiles is the same as being "in" play/textfiles, but PWD is different and therefore "cd .." gives a different result

Presumably you will get the equivalent behavior in a GUI file browser. (But MS Windows does NOT work this way)

Last edited by pixellany; 03-02-2010 at 07:47 AM.
 
  


Reply



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
hard link question - please explain it Thaidog Linux - General 3 10-02-2008 07:09 AM
Weird issues trying to post a link - Can you explain this to me? BigVig LQ Suggestions & Feedback 2 11-30-2006 03:08 PM
Symlink/Linking Question crazy4bass Linux - General 1 04-22-2005 06:37 PM
symlink question stevenhasty Linux - Newbie 4 03-31-2003 10:25 PM
Basic symlink question Zychior Linux - General 1 09-17-2002 02:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:52 PM.

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