Solved

How to use ln -s to make a symbolic link

Posted on 1998-07-16
3
575 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 37
Separate files macro - Errors on larger data set 18 65
post4 challenge 28 93
mapBully challenge 6 114
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now