Solved

How to use ln -s to make a symbolic link

Posted on 1998-07-16
3
584 Views
Last Modified: 2013-12-26
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
Comment
Question by:timothy1
3 Comments
 
LVL 5

Accepted Solution

by:
n0thing earned 100 total points
ID: 1294969
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
 

Author Comment

by:timothy1
ID: 1294970
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1294971
/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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 619
maven archtype selection in eclipse 1 57
fix34  challenge 9 143
Problem to App source 6 72
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question