Solved

How to use ln -s to make a symbolic link

Posted on 1998-07-16
3
570 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
Comment Utility
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
Comment Utility
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
Comment Utility
/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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

763 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

9 Experts available now in Live!

Get 1:1 Help Now