• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

How to use ln -s to make a symbolic link

I am trying to link a file in one directory to another file in another directory. I read the man ln and it discribed the command:

/usr/bin/ln [-fns] Source_file [Target]

Now, I understand that the first part is actual the command i.e. /usr/bin/ln

and the [-fns] are the attributes or perameters to the command, i.e. in this case -s

Is the Source_File the file you start from and the Target the file you want to go to?

Also is the /usr/bin/ actually part of the command or is that an example of a path and command, i.e. if I was already in the directory of the source file would I input just ln -s or is the /usr/bin/ln -s the whole command?

Please respond in as much plan english as possible I am new to Unix. The purpose of this question is that I installed a cgi chat program in my cgi-bin and the install instructions said that since the cgi-bin is configured not to allow HTML files to be accessed in the cgi-bin, when the cgi chat program makes the index.html file in the cgi-bin a copy of that file has to be put in the public_html directory and then linked symbolically to the original in the cgi-bin.
0
timothy1
Asked:
timothy1
1 Solution
 
n0thingCommented:
If /usr/bin is not in your current path, you'll have ot issue the whole command /usr/bin/ln even of you're in that directory.

Example: If you directory is /home/me and you want do create a symbolic link from /export/home/me --> /home/me just do:
"/usr/bin/ln -s /home/me /export/home/me"

2- If you have a file called /web/me/mydata.html and want to create a symbolic link from /web/docs/data.html
"/usr/bin/ln -s /web/me/mydata.html /web/docs/data.html"

Remember, you must have the write permission to all the directory you want to do a symlinks to.

-Minh Lai
0
 
timothy1Author Commented:
Okay, so When my cgi chat program creates the index.html file in /gladieux.com/cgi-bin/chat/

and I copy that file to:

/gladieux.com/public_html/chat/

the original index.html has a "enter" button on it that calls the chat.cgi file in the same directory it is located in. Which of course the copy doesn't have in it's directory then the command would be:

/usr/bin/ln -s /gladieux.com/public_html/chat/index.html /gladieux.com/cgi-bin/chat/index.html

meaning that when users clicked the "enter" button on the index.html file in public_html/chat/ it would go to the file in the cgi-bin or should I reverse that?

By the way, /usr/bin/ isn't in any of my directories (I use a virtual server) so I'm a little confused as to it's purpose in the command.
0
 
ahoffmannCommented:
/usr/bin/  is the path wher to find the  ln  executable. ln may also reside in another directory, common places are: /bin, /usr/bin

[-fns]  are command parameters, or exactly command options in this case (this is the UNIX terminology)
It means that  ln  may be used with the options  -f  and/or  -n  and/or  -s   which influence the behavior of the command. I.g. parameters to a command enclosed in square brackets [] are optional, while parameters in curly braces {} are mandatory.
Source_file  means that this is the original file (the real file) where the symbolic link, the Target, should point to.

Your scenario about index.html is a bit confusing: if you copy the file first, then you don't need a link (usually ln will complain). The advantage of a (symbolic) link is that you don't need to copy and therefor don't waste disk space *and* if you change the original source everyone who acceses it through the symbolic link would see the changes too.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now