Page 1 of 1

Creating a symbolic link Creating a symbolic link on the Linux Operating System Rate Topic: -----

#1 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5295
  • View blog
  • Posts: 27,178
  • Joined: 10-May 07

Post icon  Posted 02 August 2007 - 09:40 PM

What I will show you here is how to create a symbolic link on a Linux system. If you are not familiar with the Linux Operating System, you'll quickly notice that this is much more complex than the Windows simple 'network drive' usage. This method can be used to create links in & out of directories all across the File System! It's important to watch your permissions & access rights when creating your link.

It's usage is as follows:
ln [-Ffhinsv] source_file [target_file]



1st, lets show our current directory
$ pwd
/usr/home/user



Now we'll show that there is no temp directory.
$ ls -l temp
total 0



So letís create one, & then display it.
$ mkdir temp
$ ls -l | grep temp
drwxr-xr-x  2 user  user	  512 Aug  2 23:08 temp



Again, letís show that there is no directory named temp2.
$ ls -l | grep temp2
$



Here we will create a symbolic link from temp to a new directory link2. Keep in mind, we never created a directory actually named temp2!
$ ln -s temp temp2
$ ls -l | grep temp2
lrwxr-xr-x  1 user  user		4 Aug  2 23:11 temp2 -> temp



Now that we have our symbolic link created, letís echo some junk into a text file inside of our temp directory. Once we're done with that, we'll display the contents just to show it was created as intended.
$ echo junk > temp/junk.txt
$ cat temp2/junk.txt
junk



Here you will see the contents of the temp directory & then the temp2 directory, a link to the temp directory.
$ ls -l temp
total 2
-rw-r--r--  1 user  user  5 Aug  2 23:13 junk.txt
$ ls -l temp2
lrwxr-xr-x  1 user  user  4 Aug  2 23:13 temp2 -> temp



Once we're inside of the temp2 directory, we'll issue an ls showing the junk.txt text file that we created inside of temp.
$ cd temp2
$ ls
junk.txt



As you can see, once the symbolic link has been created it can be used in reference to the original temp directory. It is important to keep in mind that is simply a similar reference & not a copy! So if you remove anything inside of it, it WILL be removed from them both!

Is This A Good Question/Topic? 1
  • +

Replies To: Creating a symbolic link

#2 jyno1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-July 08

Posted 18 July 2008 - 06:32 PM

Hi,

How to create a symbolic link between directories in different servers?

My ecommance software that is uploaded to a secure SSL server needs to access to certain files in a directory in a non-secure server which has a totally different IP address. How could I create a symbolic link between, a directory "/user/htdocs/acatalog/" in 123.123.123.123 and a directory "/htdocs/acatalog/" in 111.111.111.111? The user name and passwords are different for both servers.

Many thanks,

JY
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5295
  • View blog
  • Posts: 27,178
  • Joined: 10-May 07

Posted 27 July 2008 - 01:43 AM

In order to have a link between clients, there must be software running that offers connections to the file system of that computer/server. Samba is good (& very popular) example of such a service.
Was This Post Helpful? 0
  • +
  • -

#4 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Posted 31 July 2008 - 06:17 PM

Symbolic links working over TCP/IP would be..interesting.

Edit: Create a NFS share with the files that need to be accessed remotely.

Symbolic links being accessed on a mounted drive will not work correctly! They will likely end up pointing at your local filesystem!

This post has been edited by Tom9729: 31 July 2008 - 06:19 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1