Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2011-06-28T17:34:43Z by SystemAdmin
Wardah
Wardah
1 Post
ACCEPTED ANSWER

Pinned topic Create symbolic link with different path

‏2011-06-28T08:04:39Z |
Hi,

I been looking on how to create symbolic link for my folder structure :

/BCD
/from_HUB

/proj_shared

jailshell-3.2$ ln -s proj_shared BCD/from_HUB/test
-jailshell-3.2$ cd BCD/from_HUB/
-jailshell-3.2$ ls
programs_shared projects projects_old projects_shared_old test
-jailshell-3.2$ cd test
-jailshell: cd: test: No such file or directory

I want to create BCD/from_HUB/test as the link for /proj_shared. What I got is no such file directory. Could someone help me on this ?
Thank you
Updated on 2011-06-28T17:34:43Z at 2011-06-28T17:34:43Z by SystemAdmin
  • ishields
    ishields
    988 Posts
    ACCEPTED ANSWER

    Re: Create symbolic link with different path

    ‏2011-06-28T13:07:15Z  in response to Wardah
    See Learn Linux, 101: Create and change hard and symbolic links.

    You should be able to accomplish what you want using
    
    ln -s /proj_shared /BCD/from_HUB/test
    


    Ian Shields
  • SystemAdmin
    SystemAdmin
    2364 Posts
    ACCEPTED ANSWER

    Re: Create symbolic link with different path

    ‏2011-06-28T17:34:43Z  in response to Wardah

    If you do a ls -l of BCD/from_HUB it should show you what test is actually linking.

    For example, on my laptop, I keep my user data on a separate partition from the system data. Then I link my /home directory into this structure. Here is what my root looks like when I do a listing:

    drwxr-xr-x   2 root root  4096 2011-06-21 09:04 bin
    drwxr-xr-x   3 root root  4096 2011-06-06 12:13 boot
    drwxr-xr-x   2 root root  4096 2011-06-06 00:15 cdrom
    drwxr-xr-x   4 root root  4096 2011-06-25 16:02 data
    drwxr-xr-x  18 root root  3980 2011-06-28 08:19 dev
    drwxr-xr-x 164 root root 12288 2011-06-28 12:22 etc
    -rw-r--r--   1 root root  1236 2011-03-02 08:42 GeoTrust_Global_CA.pem
    lrwxrwxrwx   1 root root    10 2011-06-25 19:27 home -> /data/home
    lrwxrwxrwx   1 root root    37 2011-06-06 00:21 initrd.img -> boot/initrd.img-2.6.32-32-generic-pae
    drwxr-xr-x  21 root root 12288 2011-06-21 08:59 lib
    drwx------   2 root root 16384 2011-06-06 00:06 lost+found
    drwxr-xr-x   3 root root  4096 2011-06-28 08:19 media
    drwxr-xr-x   2 root root  4096 2010-04-23 05:11 mnt
    drwxr-xr-x  10 root root  4096 2011-06-25 10:24 opt
    dr-xr-xr-x 265 root root     0 2011-06-27 08:33 proc
    drwx------  30 root root  4096 2011-06-28 12:24 root
    drwxr-xr-x   2 root root  4096 2011-06-21 08:59 sbin
    drwxr-xr-x   2 root root  4096 2009-12-05 15:55 selinux
    drwxr-xr-x   3 root root  4096 2011-06-08 09:49 srv
    drwxr-xr-x  13 root root     0 2011-06-27 08:33 sys
    drwxrwxrwt  54 root root 12288 2011-06-28 12:24 tmp
    drwxr-xr-x  11 root root  4096 2011-06-08 09:38 usr
    drwxr-xr-x  16 root root  4096 2011-06-06 01:14 var
    lrwxrwxrwx   1 root root    34 2011-06-06 00:21 vmlinuz -> boot/vmlinuz-2.6.32-32-generic-pa

    You can see that home points to /data/home.  You can also see the links for initrd.img and vmlinuz.

    The file system will allow you to make bogus links sometimes.  It will also not clean itself up if you remove something that was linked.  If you remove a link, it should not affect the original file (unless you do something that would be a recursive delete).  Always remember that you provide the TARGET first, then the LINK.  You may want to provide a full path in your link to make sure that it is correct:

    ln -s /home /data/home

    rather than

    ln -s home /data/home

    In the latter option, if I don't happen to be at the root (/), it may link to the wrong space.

    See if any of that helps, and let us know if you fix it!