Article ID: 1423
Last updated: 13 Oct, 2011
To create a soft links you use Linux command
ln -s /path/to/file1.txt /path/to/file2.txt To show how symlinks work on Ubuntu we created the following directories: # mkdir -p /test1/data1 # mkdir /test1/shared # mkdir -p /test2/data2 As a result the directories looks like this: # ls -al / . . drwxr-xr-x 4 root root 4096 2011-10-10 14:40 test1 drwxr-xr-x 3 root root 4096 2011-10-10 14:41 test2 . . # ls -al test1 all 16 drwxr-xr-x 4 root root 4096 2011-10-10 14:40 . drwxr-xr-x 28 root root 4096 2011-10-10 14:41 .. drwxr-xr-x 2 root root 4096 2011-10-10 14:40 data1 drwxr-xr-x 2 root root 4096 2011-10-10 14:40 shared # ls -al test2 all 12 drwxr-xr-x 3 root root 4096 2011-10-10 14:41 . drwxr-xr-x 28 root root 4096 2011-10-10 14:41 .. drwxr-xr-x 2 root root 4096 2011-10-10 14:41 data2 Then we create a new symlink in /test2 and we name the symlink 'shared' # cd /test2 # ln -s /test1/shared shared # ls -al all 12 drwxr-xr-x 3 root root 4096 2011-10-10 14:48 . drwxr-xr-x 28 root root 4096 2011-10-10 14:41 .. drwxr-xr-x 2 root root 4096 2011-10-10 14:41 data2 lrwxrwxrwx 1 root root 13 2011-10-10 14:48 shared -> /test1/shared After it's created, we use the symlink to go to the destination directory: # cd shared When the symlink is used, we're forwarded to the destination directory. If we now execute: # ls -la ../ The following output is shown: drwxr-xr-x 4 root root 4096 2011-10-04 15:18 . drwxr-xr-x 27 root root 4096 2011-10-04 15:18 .. drwxr-xr-x 2 root root 4096 2011-10-04 15:18 data1 drwxr-xr-x 2 root root 4096 2011-10-04 15:18 shared As you can see the ls command shows the content of the directory that is above the destination directory in directories structure in the remote location. Symlink to NFS share located on DSS V6 Symlinks work in exactly the same way when we mount an NFS share created on DSS V6 and create a symlink to a directory in that share. # mount -t nfs 192.168.242.73:/share/nfstest /mnt/nfs_mount # cd /mnt/nfs_mount/ # ls -al all 1140244 drwxrwxrwx 4 root root 129 2011-10-10 14:35 . drwxr-xr-x 10 root root 4096 2011-10-05 16:44 .. -rw-r--r-- 1 tomasz tomasz 383997952 2010-12-16 09:41 dss6.0up50_b4786.oe_i.iso -rw-r--r-- 1 tomasz tomasz 390416384 2011-05-06 12:01 dss6.0up75_b5377.oe_i.iso -rw-r--r-- 1 tomasz tomasz 393170944 2011-09-08 16:51 dss6.0up80_b5626.oe_i.iso drwxr-xr-x 2 root root 103 2011-10-10 14:34 userdata drwxr-xr-x 2 tomasz tomasz 4096 2011-08-29 15:35 video # cd / # mkdir kb # cd kb # ln -s /mnt/nfs_mount/userdata/ ourlink # ls -al all 8 drwxr-xr-x 2 root root 4096 2011-10-10 14:12 . drwxr-xr-x 26 root root 4096 2011-10-05 16:46 .. lrwxrwxrwx 1 root root 24 2011-10-10 14:12 ourlink -> /mnt/nfs_mount/userdata/ # cd ourlink # ls -al all 7028 drwxr-xr-x 2 root root 103 2011-10-10 14:34 . drwxrwxrwx 4 root root 4096 2011-10-10 14:35 .. -rw-r--r-- 1 tomasz tomasz 2380748 2011-08-18 15:47 trl00022_4786_logs_2011-08-18_15-20tar.gz -rw-r--r-- 1 tomasz tomasz 4804859 2011-07-06 15:50 trl00022_5377_logs_2011-07-06_12_43.tar.gz # ls -al ../ all 1140244 drwxrwxrwx 4 root root 129 2011-10-10 14:35 . drwxr-xr-x 10 root root 4096 2011-10-05 16:44 .. -rw-r--r-- 1 tomasz tomasz 383997952 2010-12-16 09:41 dss6.0up50_b4786.oe_i.iso -rw-r--r-- 1 tomasz tomasz 390416384 2011-05-06 12:01 dss6.0up75_b5377.oe_i.iso -rw-r--r-- 1 tomasz tomasz 393170944 2011-09-08 16:51 dss6.0up80_b5626.oe_i.iso drwxr-xr-x 2 root root 103 2011-10-10 14:34 userdata drwxr-xr-x 2 tomasz tomasz 4096 2011-08-29 15:35 video To summarize, when symlink is created and used, it always forwards us to the remote location. When we are moved to the remote location and we execute ls ../ The output will show us the content of the directory that is above in the directory structure in the remote location. This Knowledge Base article was prepared to prove that when a ls ../ is executed after a symlink is used, it won't show us the content of the parent directory in the local file system as some of the users claimed it should work. For some more information about soft links (symlinks, symbolic links) take a look at: http://www.cyberciti.biz/tips/understanding-unixlinux-symbolic-soft-and-hard-links.html http://linux.about.com/od/commands/l/blcmdl2_symlink.htm http://en.wikipedia.org/wiki/Symbolic_link
|
The Knowledge base is managed by Open-E data storage software company.