what is a symlink
James Gray
james at grayonline.id.au
Tue Jul 5 01:39:53 UTC 2005
On Tue, 5 Jul 2005 10:47 am, Sara Vasquez wrote:
...
> Also the only help they have is this
> http://processing.org/faq/platforms.html#linux
> where I am directed to make a symlink for the Java and the jikes folder,
> but the problem is that i din;t know what is a symlink or how to make
> one. maybe someone can tell em waht it is.
> thanks for your replies
"symlink" is a shortened version of the term "symbolic link". As the name
suggests it's a not a physical duplicate, but rather a "link" that points to
something else. In most circumstances, a symlink behaves just like the
target it points to (there are exceptions - see below).
So if I have a file /foo/bar/myfile.txt and want to refer to that file in my
home directory without having to use the full path, I create a symlink in my
home directory that points to it (logically):
/home/myhome/myfile.txt -> /foo/bar/myfile.txt
Now if I edit /home/myhome/myfile.txt I am *actually* changing the
file /foo/bar/myfile.txt. Some goes for programs, if I create a link to a
program, then execute the link, I'm actually executing the target. You can
link practically anything; files, executables, directories, even device
nodes.
Now to actually link something, you need to use the command "ln" (short for
"link"). There are two types of links: hard and symbolic (symbolic are
sometimes called "soft" links too). Don't get too concerned about hard links
for the time being - you'd rarely need to use one and when you do, you'll
KNOW that you do. Start by just using symbolic links.
So, in my example above, I wanted to link /home/myhome/myfile.txt
to /foo/bar/myfile.txt. Here's how you would do it:
ln -s /foo/bar/myfile.txt /home/myhome/myfile.txt
...if I was in my home directory to start with, I could simply do:
ln -s /foo/bar/myfile.txt
The "-s" means "symbolic link" as ln by default tries to make hard links.
The general form is very similar to the "cp" command:
ln -s target link-name
So in my example, "/foo/bar/myfile.txt" is the target, and
"/home/myhome/myfile.txt" is the link name.
Here's a few tips:
1. the link name can be totally different to the target name, eg;
ln -s program-name myprogram
This basically says "I want to refer to program-name as myprogram as well"
2. link targets can be relative to the link name, eg;
cd ~ (ie, cd to /home/myuserid/)
ln -s ../../etc/profile .profile
This will link the system-wide shell config to your home directory. BUT
unless you can edit /etc/profile you'll be stuck with whatever your
sysadmin has deemed "default".
3. Deleting a symbolic link only deletes the link, not the target.
4. Symbolic links inherit the permissions of the target - don't be fooled when
you see the permissions of a link being world-read+write+exec. ;)
5. Pay careful attention to file commands (cp, mv, tar, etc) because the way
symbolic links are handled is sometimes a little non-intuitive. This is
what I was referring to when I said links don't always behave like a
regular file. "man cp", "man mv", "man tar" etc, are your friends.
Well, that's a crash course in file system links. For all the details:
"man ln"
Cheers,
James
--
Woke up this mornin' an' I had myself a beer,
Yeah, Ah woke up this mornin' an' I had myself a beer
The future's uncertain and the end is always near.
-- Jim Morrison, "Roadhouse Blues"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/kubuntu-users/attachments/20050705/c614cecd/attachment.sig>
More information about the kubuntu-users
mailing list