Solved

How to use ln -s to make a symbolic link

Posted on 1998-07-16
3
595 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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